2 * Copyright (c) 1996, Javier MartÃn Rueda (jmrueda@diatel.upm.es)
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * $FreeBSD: src/sys/dev/ex/if_ex.c,v 1.26.2.3 2001/03/05 05:33:20 imp Exp $
28 * $DragonFly: src/sys/dev/netif/ex/if_ex.c,v 1.9 2004/03/23 22:19:00 hsu Exp $
30 * MAINTAINER: Matthew N. Dodd <winter@jurai.net>
35 * Intel EtherExpress Pro/10, Pro/10+ Ethernet driver
39 * 30-Oct-1996: first beta version. Inet and BPF supported, but no multicast.
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/kernel.h>
45 #include <sys/sockio.h>
47 #include <sys/socket.h>
49 #include <sys/module.h>
52 #include <machine/bus.h>
53 #include <machine/resource.h>
57 #include <net/if_arp.h>
58 #include <net/if_media.h>
59 #include <net/ethernet.h>
62 #include <netinet/in.h>
63 #include <netinet/if_ether.h>
64 #include <machine/clock.h>
67 #include <bus/isa/isavar.h>
68 #include <bus/isa/pnpvar.h>
73 DECLARE_DUMMY_MODULE(if_ex);
80 static int debug_mask = 0;
81 static int exintr_count = 0;
82 # define DODEBUG(level, action) if (level & debug_mask) action
84 # define DODEBUG(level, action)
88 { -1, -1, 0, 1, -1, 2, -1, -1, -1, 0, 3, 4, -1, -1, -1, -1 };
90 { 9, 3, 5, 10, 11, 0, 0, 0 };
92 char plus_irq2eemap[] =
93 { -1, -1, -1, 0, 1, 2, -1, 3, -1, 4, 5, 6, 7, -1, -1, -1 };
94 u_char plus_ee2irqmap[] =
95 { 3, 4, 5, 7, 9, 10, 11, 12 };
97 /* Network Interface Functions */
98 static void ex_init (void *);
99 static void ex_start (struct ifnet *);
100 static int ex_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *);
101 static void ex_watchdog (struct ifnet *);
103 /* ifmedia Functions */
104 static int ex_ifmedia_upd (struct ifnet *);
105 static void ex_ifmedia_sts (struct ifnet *, struct ifmediareq *);
107 static int ex_get_media (u_int32_t iobase);
109 static void ex_reset (struct ex_softc *);
111 static void ex_tx_intr (struct ex_softc *);
112 static void ex_rx_intr (struct ex_softc *);
115 look_for_card (u_int32_t iobase)
120 * Check for the i82595 signature, and check that the round robin
121 * counter actually advances.
123 if (((count1 = inb(iobase + ID_REG)) & Id_Mask) != Id_Sig)
125 count2 = inb(iobase + ID_REG);
126 count2 = inb(iobase + ID_REG);
127 count2 = inb(iobase + ID_REG);
129 return((count2 & Counter_bits) == ((count1 + 0xc0) & Counter_bits));
133 ex_get_address (u_int32_t iobase, u_char *enaddr)
137 eaddr_tmp = eeprom_read(iobase, EE_Eth_Addr_Lo);
138 enaddr[5] = eaddr_tmp & 0xff;
139 enaddr[4] = eaddr_tmp >> 8;
140 eaddr_tmp = eeprom_read(iobase, EE_Eth_Addr_Mid);
141 enaddr[3] = eaddr_tmp & 0xff;
142 enaddr[2] = eaddr_tmp >> 8;
143 eaddr_tmp = eeprom_read(iobase, EE_Eth_Addr_Hi);
144 enaddr[1] = eaddr_tmp & 0xff;
145 enaddr[0] = eaddr_tmp >> 8;
151 ex_card_type (u_char *enaddr)
153 if ((enaddr[0] == 0x00) && (enaddr[1] == 0xA0) && (enaddr[2] == 0xC9))
154 return (CARD_TYPE_EX_10_PLUS);
156 return (CARD_TYPE_EX_10);
160 * Caller is responsible for eventually calling
161 * ex_release_resources() on failure.
164 ex_alloc_resources (device_t dev)
166 struct ex_softc * sc = device_get_softc(dev);
169 sc->ioport = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->ioport_rid,
170 0, ~0, 1, RF_ACTIVE);
172 device_printf(dev, "No I/O space?!\n");
177 sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
178 0, ~0, 1, RF_ACTIVE);
181 device_printf(dev, "No IRQ?!\n");
191 ex_release_resources (device_t dev)
193 struct ex_softc * sc = device_get_softc(dev);
196 bus_teardown_intr(dev, sc->irq, sc->ih);
201 bus_release_resource(dev, SYS_RES_IOPORT,
202 sc->ioport_rid, sc->ioport);
207 bus_release_resource(dev, SYS_RES_IRQ,
208 sc->irq_rid, sc->irq);
216 ex_attach(device_t dev)
218 struct ex_softc * sc = device_get_softc(dev);
219 struct ifnet * ifp = &sc->arpcom.ac_if;
220 struct ifmedia * ifm;
221 int unit = device_get_unit(dev);
224 /* work out which set of irq <-> internal tables to use */
225 if (ex_card_type(sc->arpcom.ac_enaddr) == CARD_TYPE_EX_10_PLUS) {
226 sc->irq2ee = plus_irq2eemap;
227 sc->ee2irq = plus_ee2irqmap;
229 sc->irq2ee = irq2eemap;
230 sc->ee2irq = ee2irqmap;
233 sc->mem_size = CARD_RAM_SIZE; /* XXX This should be read from the card itself. */
236 * Initialize the ifnet structure.
239 if_initname(ifp, "ex", unit);
240 ifp->if_mtu = ETHERMTU;
241 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST /* XXX not done yet. | IFF_MULTICAST */;
242 ifp->if_output = ether_output;
243 ifp->if_start = ex_start;
244 ifp->if_ioctl = ex_ioctl;
245 ifp->if_watchdog = ex_watchdog;
246 ifp->if_init = ex_init;
247 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
249 ifmedia_init(&sc->ifmedia, 0, ex_ifmedia_upd, ex_ifmedia_sts);
251 temp = eeprom_read(sc->iobase, EE_W5);
252 if (temp & EE_W5_PORT_TPE)
253 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL);
254 if (temp & EE_W5_PORT_BNC)
255 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_2, 0, NULL);
256 if (temp & EE_W5_PORT_AUI)
257 ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_5, 0, NULL);
259 ifmedia_set(&sc->ifmedia, ex_get_media(sc->iobase));
262 ifm->ifm_media = ifm->ifm_cur->ifm_media;
266 * Attach the interface.
268 ether_ifattach(ifp, sc->arpcom.ac_enaddr);
270 device_printf(sc->dev, "Ethernet address %6D\n",
271 sc->arpcom.ac_enaddr, ":");
279 struct ex_softc * sc = (struct ex_softc *) xsc;
280 struct ifnet * ifp = &sc->arpcom.ac_if;
283 register int iobase = sc->iobase;
284 unsigned short temp_reg;
286 DODEBUG(Start_End, printf("ex_init%d: start\n", ifp->if_dunit););
288 if (TAILQ_FIRST(&ifp->if_addrhead) == NULL) {
295 * Load the ethernet address into the card.
297 outb(iobase + CMD_REG, Bank2_Sel);
298 temp_reg = inb(iobase + EEPROM_REG);
299 if (temp_reg & Trnoff_Enable) {
300 outb(iobase + EEPROM_REG, temp_reg & ~Trnoff_Enable);
302 for (i = 0; i < ETHER_ADDR_LEN; i++) {
303 outb(iobase + I_ADDR_REG0 + i, sc->arpcom.ac_enaddr[i]);
306 * - Setup transmit chaining and discard bad received frames.
309 * - Set receiving mode.
312 outb(iobase + REG1, inb(iobase + REG1) | Tx_Chn_Int_Md | Tx_Chn_ErStp | Disc_Bad_Fr);
313 outb(iobase + REG2, inb(iobase + REG2) | No_SA_Ins | RX_CRC_InMem);
314 outb(iobase + REG3, inb(iobase + REG3) & 0x3f /* XXX constants. */ );
315 outb(iobase + CMD_REG, Bank1_Sel);
316 outb(iobase + INT_NO_REG, (inb(iobase + INT_NO_REG) & 0xf8) | sc->irq2ee[sc->irq_no]);
319 * Divide the available memory in the card into rcv and xmt buffers.
320 * By default, I use the first 3/4 of the memory for the rcv buffer,
321 * and the remaining 1/4 of the memory for the xmt buffer.
323 sc->rx_mem_size = sc->mem_size * 3 / 4;
324 sc->tx_mem_size = sc->mem_size - sc->rx_mem_size;
325 sc->rx_lower_limit = 0x0000;
326 sc->rx_upper_limit = sc->rx_mem_size - 2;
327 sc->tx_lower_limit = sc->rx_mem_size;
328 sc->tx_upper_limit = sc->mem_size - 2;
329 outb(iobase + RCV_LOWER_LIMIT_REG, sc->rx_lower_limit >> 8);
330 outb(iobase + RCV_UPPER_LIMIT_REG, sc->rx_upper_limit >> 8);
331 outb(iobase + XMT_LOWER_LIMIT_REG, sc->tx_lower_limit >> 8);
332 outb(iobase + XMT_UPPER_LIMIT_REG, sc->tx_upper_limit >> 8);
335 * Enable receive and transmit interrupts, and clear any pending int.
337 outb(iobase + REG1, inb(iobase + REG1) | TriST_INT);
338 outb(iobase + CMD_REG, Bank0_Sel);
339 outb(iobase + MASK_REG, All_Int & ~(Rx_Int | Tx_Int));
340 outb(iobase + STATUS_REG, All_Int);
343 * Initialize receive and transmit ring buffers.
345 outw(iobase + RCV_BAR, sc->rx_lower_limit);
346 sc->rx_head = sc->rx_lower_limit;
347 outw(iobase + RCV_STOP_REG, sc->rx_upper_limit | 0xfe);
348 outw(iobase + XMT_BAR, sc->tx_lower_limit);
349 sc->tx_head = sc->tx_tail = sc->tx_lower_limit;
351 ifp->if_flags |= IFF_RUNNING;
352 ifp->if_flags &= ~IFF_OACTIVE;
353 DODEBUG(Status, printf("OIDLE init\n"););
356 * Final reset of the board, and enable operation.
358 outb(iobase + CMD_REG, Sel_Reset_CMD);
360 outb(iobase + CMD_REG, Rcv_Enable_CMD);
365 DODEBUG(Start_End, printf("ex_init%d: finish\n", ifp->if_dunit););
370 ex_start(struct ifnet *ifp)
372 struct ex_softc * sc = ifp->if_softc;
373 int iobase = sc->iobase;
374 int i, s, len, data_len, avail, dest, next;
375 unsigned char tmp16[2];
379 DODEBUG(Start_End, printf("ex_start%d: start\n", unit););
384 * Main loop: send outgoing packets to network card until there are no
385 * more packets left, or the card cannot accept any more yet.
387 while (((opkt = ifp->if_snd.ifq_head) != NULL) &&
388 !(ifp->if_flags & IFF_OACTIVE)) {
391 * Ensure there is enough free transmit buffer space for
392 * this packet, including its header. Note: the header
393 * cannot wrap around the end of the transmit buffer and
394 * must be kept together, so we allow space for twice the
395 * length of the header, just in case.
398 for (len = 0, m = opkt; m != NULL; m = m->m_next) {
404 DODEBUG(Sent_Pkts, printf("1. Sending packet with %d data bytes. ", data_len););
407 len += XMT_HEADER_LEN + 1;
409 len += XMT_HEADER_LEN;
412 if ((i = sc->tx_tail - sc->tx_head) >= 0) {
413 avail = sc->tx_mem_size - i;
418 DODEBUG(Sent_Pkts, printf("i=%d, avail=%d\n", i, avail););
420 if (avail >= len + XMT_HEADER_LEN) {
421 IF_DEQUEUE(&ifp->if_snd, opkt);
425 * Disable rx and tx interrupts, to avoid corruption
426 * of the host address register by interrupt service
428 * XXX Is this necessary with splimp() enabled?
430 outb(iobase + MASK_REG, All_Int);
434 * Compute the start and end addresses of this
435 * frame in the tx buffer.
440 if (next > sc->tx_upper_limit) {
441 if ((sc->tx_upper_limit + 2 - sc->tx_tail) <=
443 dest = sc->tx_lower_limit;
446 next = sc->tx_lower_limit +
447 next - sc->tx_upper_limit - 2;
452 * Build the packet frame in the card's ring buffer.
454 DODEBUG(Sent_Pkts, printf("2. dest=%d, next=%d. ", dest, next););
456 outw(iobase + HOST_ADDR_REG, dest);
457 outw(iobase + IO_PORT_REG, Transmit_CMD);
458 outw(iobase + IO_PORT_REG, 0);
459 outw(iobase + IO_PORT_REG, next);
460 outw(iobase + IO_PORT_REG, data_len);
463 * Output the packet data to the card. Ensure all
464 * transfers are 16-bit wide, even if individual
465 * mbufs have odd length.
468 for (m = opkt, i = 0; m != NULL; m = m->m_next) {
469 DODEBUG(Sent_Pkts, printf("[%d]", m->m_len););
471 tmp16[1] = *(mtod(m, caddr_t));
472 outsw(iobase + IO_PORT_REG, tmp16, 1);
474 outsw(iobase + IO_PORT_REG,
475 mtod(m, caddr_t) + i, (m->m_len - i) / 2);
477 if ((i = (m->m_len - i) & 1) != 0) {
478 tmp16[0] = *(mtod(m, caddr_t) +
483 outsw(iobase + IO_PORT_REG, tmp16, 1);
487 * If there were other frames chained, update the
488 * chain in the last one.
490 if (sc->tx_head != sc->tx_tail) {
491 if (sc->tx_tail != dest) {
492 outw(iobase + HOST_ADDR_REG,
493 sc->tx_last + XMT_Chain_Point);
494 outw(iobase + IO_PORT_REG, dest);
496 outw(iobase + HOST_ADDR_REG,
497 sc->tx_last + XMT_Byte_Count);
498 i = inw(iobase + IO_PORT_REG);
499 outw(iobase + HOST_ADDR_REG,
500 sc->tx_last + XMT_Byte_Count);
501 outw(iobase + IO_PORT_REG, i | Ch_bit);
505 * Resume normal operation of the card:
506 * - Make a dummy read to flush the DRAM write
508 * - Enable receive and transmit interrupts.
509 * - Send Transmit or Resume_XMT command, as
512 inw(iobase + IO_PORT_REG);
514 outb(iobase + MASK_REG, All_Int & ~(Rx_Int | Tx_Int));
516 if (sc->tx_head == sc->tx_tail) {
517 outw(iobase + XMT_BAR, dest);
518 outb(iobase + CMD_REG, Transmit_CMD);
520 DODEBUG(Sent_Pkts, printf("Transmit\n"););
522 outb(iobase + CMD_REG, Resume_XMT_List_CMD);
523 DODEBUG(Sent_Pkts, printf("Resume\n"););
529 if (ifp->if_bpf != NULL) {
537 ifp->if_flags |= IFF_OACTIVE;
538 DODEBUG(Status, printf("OACTIVE start\n"););
544 DODEBUG(Start_End, printf("ex_start%d: finish\n", unit););
548 ex_stop(struct ex_softc *sc)
550 int iobase = sc->iobase;
552 DODEBUG(Start_End, printf("ex_stop%d: start\n", unit););
555 * Disable card operation:
556 * - Disable the interrupt line.
557 * - Flush transmission and disable reception.
558 * - Mask and clear all interrupts.
561 outb(iobase + CMD_REG, Bank1_Sel);
562 outb(iobase + REG1, inb(iobase + REG1) & ~TriST_INT);
563 outb(iobase + CMD_REG, Bank0_Sel);
564 outb(iobase + CMD_REG, Rcv_Stop);
565 sc->tx_head = sc->tx_tail = sc->tx_lower_limit;
566 sc->tx_last = 0; /* XXX I think these two lines are not necessary, because ex_init will always be called again to reinit the interface. */
567 outb(iobase + MASK_REG, All_Int);
568 outb(iobase + STATUS_REG, All_Int);
569 outb(iobase + CMD_REG, Reset_CMD);
572 DODEBUG(Start_End, printf("ex_stop%d: finish\n", unit););
580 struct ex_softc * sc = (struct ex_softc *)arg;
581 struct ifnet * ifp = &sc->arpcom.ac_if;
582 int iobase = sc->iobase;
583 int int_status, send_pkts;
585 DODEBUG(Start_End, printf("ex_intr%d: start\n", unit););
588 if (++exintr_count != 1)
589 printf("WARNING: nested interrupt (%d). Mail the author.\n", exintr_count);
593 while ((int_status = inb(iobase + STATUS_REG)) & (Tx_Int | Rx_Int)) {
594 if (int_status & Rx_Int) {
595 outb(iobase + STATUS_REG, Rx_Int);
598 } else if (int_status & Tx_Int) {
599 outb(iobase + STATUS_REG, Tx_Int);
607 * If any packet has been transmitted, and there are queued packets to
608 * be sent, attempt to send more packets to the network card.
611 if (send_pkts && (ifp->if_snd.ifq_head != NULL)) {
619 DODEBUG(Start_End, printf("ex_intr%d: finish\n", unit););
625 ex_tx_intr(struct ex_softc *sc)
627 struct ifnet * ifp = &sc->arpcom.ac_if;
628 int iobase = sc->iobase;
631 DODEBUG(Start_End, printf("ex_tx_intr%d: start\n", unit););
634 * - Cancel the watchdog.
635 * For all packets transmitted since last transmit interrupt:
636 * - Advance chain pointer to next queued packet.
637 * - Update statistics.
642 while (sc->tx_head != sc->tx_tail) {
643 outw(iobase + HOST_ADDR_REG, sc->tx_head);
645 if (! inw(iobase + IO_PORT_REG) & Done_bit)
648 tx_status = inw(iobase + IO_PORT_REG);
649 sc->tx_head = inw(iobase + IO_PORT_REG);
651 if (tx_status & TX_OK_bit) {
657 ifp->if_collisions += tx_status & No_Collisions_bits;
661 * The card should be ready to accept more packets now.
664 ifp->if_flags &= ~IFF_OACTIVE;
666 DODEBUG(Status, printf("OIDLE tx_intr\n"););
667 DODEBUG(Start_End, printf("ex_tx_intr%d: finish\n", unit););
673 ex_rx_intr(struct ex_softc *sc)
675 struct ifnet * ifp = &sc->arpcom.ac_if;
676 int iobase = sc->iobase;
682 struct ether_header * eh;
684 DODEBUG(Start_End, printf("ex_rx_intr%d: start\n", unit););
687 * For all packets received since last receive interrupt:
688 * - If packet ok, read it into a new mbuf and queue it to interface,
689 * updating statistics.
690 * - If packet bad, just discard it, and update statistics.
691 * Finally, advance receive stop limit in card's memory to new location.
694 outw(iobase + HOST_ADDR_REG, sc->rx_head);
696 while (inw(iobase + IO_PORT_REG) == RCV_Done) {
698 rx_status = inw(iobase + IO_PORT_REG);
699 sc->rx_head = inw(iobase + IO_PORT_REG);
700 QQQ = pkt_len = inw(iobase + IO_PORT_REG);
702 if (rx_status & RCV_OK_bit) {
703 MGETHDR(m, M_DONTWAIT, MT_DATA);
708 ipkt->m_pkthdr.rcvif = ifp;
709 ipkt->m_pkthdr.len = pkt_len;
712 while (pkt_len > 0) {
713 if (pkt_len > MINCLSIZE) {
714 MCLGET(m, M_DONTWAIT);
715 if (m->m_flags & M_EXT) {
723 m->m_len = min(m->m_len, pkt_len);
726 * NOTE: I'm assuming that all mbufs allocated are of even length,
727 * except for the last one in an odd-length packet.
730 insw(iobase + IO_PORT_REG,
731 mtod(m, caddr_t), m->m_len / 2);
734 *(mtod(m, caddr_t) + m->m_len - 1) = inb(iobase + IO_PORT_REG);
739 MGET(m->m_next, M_DONTWAIT, MT_DATA);
740 if (m->m_next == NULL) {
749 eh = mtod(ipkt, struct ether_header *);
751 if (debug_mask & Rcvd_Pkts) {
752 if ((eh->ether_dhost[5] != 0xff) || (eh->ether_dhost[0] != 0xff)) {
753 printf("Receive packet with %d data bytes: %6D -> ", QQQ, eh->ether_shost, ":");
754 printf("%6D\n", eh->ether_dhost, ":");
758 m_adj(ipkt, sizeof(struct ether_header));
759 ether_input(ifp, eh, ipkt);
765 outw(iobase + HOST_ADDR_REG, sc->rx_head);
769 if (sc->rx_head < sc->rx_lower_limit + 2)
770 outw(iobase + RCV_STOP_REG, sc->rx_upper_limit);
772 outw(iobase + RCV_STOP_REG, sc->rx_head - 2);
774 DODEBUG(Start_End, printf("ex_rx_intr%d: finish\n", unit););
781 ex_ioctl(register struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
783 struct ex_softc * sc = ifp->if_softc;
784 struct ifreq * ifr = (struct ifreq *)data;
788 DODEBUG(Start_End, printf("ex_ioctl%d: start ", ifp->if_dunit););
796 error = ether_ioctl(ifp, cmd, data);
800 DODEBUG(Start_End, printf("SIOCSIFFLAGS"););
801 if ((ifp->if_flags & IFF_UP) == 0 &&
802 (ifp->if_flags & IFF_RUNNING)) {
804 ifp->if_flags &= ~IFF_RUNNING;
812 DODEBUG(Start_End, printf("SIOCGHWADDR"););
813 bcopy((caddr_t)sc->sc_addr, (caddr_t)&ifr->ifr_data,
814 sizeof(sc->sc_addr));
818 DODEBUG(Start_End, printf("SIOCADDMULTI"););
820 DODEBUG(Start_End, printf("SIOCDELMULTI"););
821 /* XXX Support not done yet. */
826 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
829 DODEBUG(Start_End, printf("unknown"););
835 DODEBUG(Start_End, printf("\nex_ioctl%d: finish\n", ifp->if_dunit););
842 ex_reset(struct ex_softc *sc)
846 DODEBUG(Start_End, printf("ex_reset%d: start\n", unit););
855 DODEBUG(Start_End, printf("ex_reset%d: finish\n", unit););
861 ex_watchdog(struct ifnet *ifp)
863 struct ex_softc * sc = ifp->if_softc;
865 DODEBUG(Start_End, printf("ex_watchdog%d: start\n", ifp->if_dunit););
867 ifp->if_flags &= ~IFF_OACTIVE;
869 DODEBUG(Status, printf("OIDLE watchdog\n"););
875 DODEBUG(Start_End, printf("ex_watchdog%d: finish\n", ifp->if_dunit););
881 ex_get_media (u_int32_t iobase)
885 outb(iobase + CMD_REG, Bank2_Sel);
886 tmp = inb(iobase + REG3);
887 outb(iobase + CMD_REG, Bank0_Sel);
890 return(IFM_ETHER|IFM_10_T);
892 return(IFM_ETHER|IFM_10_2);
894 return (IFM_ETHER|IFM_10_5);
906 ex_ifmedia_sts(ifp, ifmr)
908 struct ifmediareq * ifmr;
910 struct ex_softc * sc = ifp->if_softc;
912 ifmr->ifm_active = ex_get_media(sc->iobase);
918 eeprom_read(u_int32_t iobase, int location)
923 int read_cmd = location | EE_READ_CMD;
924 short ctrl_val = EECS;
926 ee_addr = iobase + EEPROM_REG;
927 outb(iobase + CMD_REG, Bank2_Sel);
929 for (i = 8; i >= 0; i--) {
930 short outval = (read_cmd & (1 << i)) ? ctrl_val | EEDI : ctrl_val;
931 outb(ee_addr, outval);
932 outb(ee_addr, outval | EESK);
934 outb(ee_addr, outval);
937 outb(ee_addr, ctrl_val);
939 for (i = 16; i > 0; i--) {
940 outb(ee_addr, ctrl_val | EESK);
942 data = (data << 1) | ((inb(ee_addr) & EEDO) ? 1 : 0);
943 outb(ee_addr, ctrl_val);
948 outb(ee_addr, ctrl_val | EESK);
950 outb(ee_addr, ctrl_val);
952 outb(iobase + CMD_REG, Bank0_Sel);