Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Split the arm26 Ether3 (ea) driver into an MI driver for...



details:   https://anonhg.NetBSD.org/src/rev/e86ed032009c
branches:  trunk
changeset: 497086:e86ed032009c
user:      bjh21 <bjh21%NetBSD.org@localhost>
date:      Mon Sep 18 20:51:14 2000 +0000

description:
Split the arm26 Ether3 (ea) driver into an MI driver for the SEEQ 8005 chip,
and a front-end driver for the Ether3.  Only semantic change is to remove
ea_claimirq() and ea_releaseirq() on the grounds that the seem too spurious
to warrant a callback to the front-end.

diffstat:

 sys/arch/arm26/conf/files.arm26     |     4 +-
 sys/arch/arm26/podulebus/if_ea.c    |  1412 +----------------------------------
 sys/arch/arm26/podulebus/if_eareg.h |   114 +--
 sys/conf/files                      |     6 +-
 sys/dev/ic/seeq8005.c               |  1398 ++++++++++++++++++++++++++++++++++
 sys/dev/ic/seeq8005reg.h            |   145 +++
 sys/dev/ic/seeq8005var.h            |    58 +
 7 files changed, 1624 insertions(+), 1513 deletions(-)

diffs (truncated from 3263 to 300 lines):

diff -r 838a9652a5bb -r e86ed032009c sys/arch/arm26/conf/files.arm26
--- a/sys/arch/arm26/conf/files.arm26   Mon Sep 18 20:08:43 2000 +0000
+++ b/sys/arch/arm26/conf/files.arm26   Mon Sep 18 20:51:14 2000 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.arm26,v 1.5 2000/09/18 20:08:43 bjh21 Exp $
+# $NetBSD: files.arm26,v 1.6 2000/09/18 20:51:15 bjh21 Exp $
 
 # Copyright (c) 1997, 1998, 2000 Ben Harris
 # All rights reserved.
@@ -167,7 +167,7 @@
 file   arch/arm26/podulebus/if_ei.c            ei
 
 # Acorn/Atomwide Ether3
-device ea: ether, ifnet, arp
+device ea: ether, ifnet, arp, seeq8005
 attach ea at podulebus
 file   arch/arm26/podulebus/if_ea.c            ea
 
diff -r 838a9652a5bb -r e86ed032009c sys/arch/arm26/podulebus/if_ea.c
--- a/sys/arch/arm26/podulebus/if_ea.c  Mon Sep 18 20:08:43 2000 +0000
+++ b/sys/arch/arm26/podulebus/if_ea.c  Mon Sep 18 20:51:14 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ea.c,v 1.18 2000/08/22 21:22:49 bjh21 Exp $ */
+/* $NetBSD: if_ea.c,v 1.19 2000/09/18 20:51:15 bjh21 Exp $ */
 
 /*
  * Copyright (c) 2000 Ben Harris
@@ -36,190 +36,49 @@
  * if_ea.c - Ether3 device driver
  */
 
-/*
- * SEEQ 8005 device driver
- */
-
-/*
- * Bugs/possible improvements:
- *     - Does not currently support DMA
- *     - Does not currently support multicasts
- *     - Does not transmit multiple packets in one go
- *     - Does not support big-endian hosts
- *     - Does not support 8-bit busses
- */
-
-#include "opt_inet.h"
-#include "opt_ns.h"
-
-#include <sys/types.h>
 #include <sys/param.h>
 
-__RCSID("$NetBSD: if_ea.c,v 1.18 2000/08/22 21:22:49 bjh21 Exp $");
-
-#include <sys/systm.h>
-#include <sys/endian.h>
-#include <sys/errno.h>
-#include <sys/ioctl.h>
-#include <sys/mbuf.h>
-#include <sys/socket.h>
-#include <sys/syslog.h>
-#include <sys/device.h>
-
-#include <net/if.h>
-#include <net/if_dl.h>
-#include <net/if_types.h>
-#include <net/if_ether.h>
+__RCSID("$NetBSD: if_ea.c,v 1.19 2000/09/18 20:51:15 bjh21 Exp $");
 
-#ifdef INET
-#include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/in_var.h>
-#include <netinet/ip.h>
-#include <netinet/if_inarp.h>
-#endif
-
-#ifdef NS
-#include <netns/ns.h>
-#include <netns/ns_if.h>
-#endif
-
-#include "bpfilter.h"
-#if NBPFILTER > 0
-#include <net/bpf.h>
-#include <net/bpfdesc.h>
-#endif
+#include <sys/device.h>
+#include <sys/socket.h>
+#include <sys/systm.h>
 
 #include <machine/bus.h>
-#include <machine/cpu.h>
 #include <machine/intr.h>
 #include <machine/irq.h>
 
-#include <arm26/podulebus/if_eareg.h>
+#include <net/if.h>
+#include <net/if_ether.h>
+
 #include <arm26/podulebus/podulebus.h>
 #include <arm32/podulebus/podules.h>
 
-#ifndef EA_TIMEOUT
-#define EA_TIMEOUT     60
-#endif
-
-#define EA_TX_BUFFER_SIZE      0x4000
-#define EA_RX_BUFFER_SIZE      0xC000
-
-/*#define EA_TX_DEBUG*/
-/*#define EA_RX_DEBUG*/
-/*#define EA_DEBUG*/
-/*#define EA_PACKET_DEBUG*/
-
-/* for debugging convenience */
-#ifdef EA_DEBUG
-#define dprintf(x) printf x
-#else
-#define dprintf(x)
-#endif
+#include <arm26/podulebus/if_eareg.h>
+#include <dev/ic/seeq8005var.h>
 
 /*
  * per-line info and status
  */
 
 struct ea_softc {
-       struct device sc_dev;
+       struct seeq8005_softc   sc_8005;
        struct irq_handler *sc_ih;
-       bus_space_tag_t sc_iot;         /* I/O base addr */
-       bus_space_handle_t sc_ioh;
-       struct ethercom sc_ethercom;    /* Ethernet common */
-       int sc_config1;                 /* Current config1 bits */
-       int sc_config2;                 /* Current config2 bits */
-       int sc_command;                 /* Current command bits */
-       int sc_irqclaimed;              /* Whether we have an IRQ claimed */
-       u_int sc_rx_ptr;                /* Receive buffer pointer */
-       u_int sc_tx_ptr;                /* Transmit buffer pointer */
 };
 
 /*
  * prototypes
  */
 
-int eaintr(void *);
-static int ea_init(struct ea_softc *);
-static int ea_ioctl(struct ifnet *, u_long, caddr_t);
-static void ea_start(struct ifnet *);
-static void ea_watchdog(struct ifnet *);
-static void ea_reinit(struct ea_softc *);
-static void ea_chipreset(struct ea_softc *);
-static void ea_ramtest(struct ea_softc *);
-static int ea_stoptx(struct ea_softc *);
-static int ea_stoprx(struct ea_softc *);
-static void ea_stop(struct ea_softc *);
-static void ea_await_fifo_empty(struct ea_softc *);
-static void ea_await_fifo_full(struct ea_softc *);
-static void ea_writebuf(struct ea_softc *, u_char *, u_int, size_t);
-static void ea_readbuf(struct ea_softc *, u_char *, u_int, size_t);
-static void earead(struct ea_softc *, int, int);
-static struct mbuf *eaget(struct ea_softc *, int, int, struct ifnet *);
-static void ea_hardreset(struct ea_softc *);
-static void eagetpackets(struct ea_softc *);
-static void eatxpacket(struct ea_softc *);
-
 int eaprobe(struct device *, struct cfdata *, void *);
 void eaattach(struct device *, struct device *, void *);
 
-#ifdef EA_PACKET_DEBUG
-void ea_dump_buffer(struct ea_softc *, int);
-#endif
-void ea_claimirq(struct ea_softc *);
-void ea_releaseirq(struct ea_softc *);
-
 /* driver structure for autoconf */
 
 struct cfattach ea_ca = {
        sizeof(struct ea_softc), eaprobe, eaattach
 };
 
-#ifdef EA_PACKET_DEBUG
-/*
- * Dump the interface buffer
- */
-
-void
-ea_dump_buffer(struct ea_softc *sc, u_int offset)
-{
-       bus_space_tag_t iot = sc->sc_iot;
-       bus_space_handle_t ioh = sc->sc_ioh;
-       u_int addr;
-       int loop;
-       size_t size;
-       int ctrl;
-       int ptr;
-       
-       addr = offset;
-
-       do {
-               bus_space_write_2(iot, ioh, EA_8005_COMMAND,
-                                sc->sc_command | EA_CMD_FIFO_READ);
-               bus_space_write_2(iot, ioh, EA_8005_CONFIG1,
-                                 sc->sc_config1 | EA_BUFCODE_LOCAL_MEM);
-               bus_space_write_2(iot, ioh, EA_8005_DMA_ADDR, addr);
-
-               ptr = bus_space_read_2(iot, ioh, EA_8005_BUFWIN);
-               ctrl = bus_space_read_2(iot, ioh, EA_8005_BUFWIN);
-               ptr = ((ptr & 0xff) << 8) | ((ptr >> 8) & 0xff);
-
-               if (ptr == 0) break;
-               size = ptr - addr;
-
-               printf("addr=%04x size=%04x ", addr, size);
-               printf("cmd=%02x st=%02x\n", ctrl & 0xff, ctrl >> 8);
-
-               for (loop = 0; loop < size - 4; loop += 2)
-                       printf("%04x ",
-                              bus_space_read_2(iot, ioh, EA_8005_BUFWIN));
-               printf("\n");
-               addr = ptr;
-       } while (size != 0);
-}
-#endif
-
 /*
  * Probe routine.
  */
@@ -253,7 +112,6 @@
 {
        struct ea_softc *sc = (void *)self;
        struct podulebus_attach_args *pa = aux;
-       struct ifnet *ifp = &sc->sc_ethercom.ec_if;
        u_int8_t myaddr[ETHER_ADDR_LEN];
        char *ptr;
        int i;
@@ -262,7 +120,7 @@
 
        /* Set the address of the controller for easy access */
        bus_space_shift(pa->pa_memc_t, pa->pa_memc_h, EA_8005_SHIFT,
-                       &sc->sc_iot, &sc->sc_ioh);
+                       &sc->sc_8005.sc_iot, &sc->sc_8005.sc_ioh);
 
        /* Get the Ethernet address from the device description string. */
        if (pa->pa_descr == NULL) {
@@ -284,1253 +142,13 @@
                }
        }
 
-       /* Print out some information for the user. */
-
-       printf(": address %s", ether_sprintf(myaddr));
-
-       sc->sc_irqclaimed = 0;
+       seeq8005_attach(&sc->sc_8005, myaddr);
 
        /* Claim a podule interrupt */
 
-       sc->sc_ih = podulebus_irq_establish(sc->sc_dev.dv_parent,
-           pa->pa_slotnum, IPL_NET, eaintr, sc);
-
-       /* Stop the board. */
-
-       ea_chipreset(sc);
-       ea_stoptx(sc);
-       ea_stoprx(sc);
-
-       /* Initialise ifnet structure. */
-
-       bcopy(sc->sc_dev.dv_xname, ifp->if_xname, IFNAMSIZ);
-       ifp->if_softc = sc;
-       ifp->if_start = ea_start;
-       ifp->if_ioctl = ea_ioctl;
-       ifp->if_watchdog = ea_watchdog;
-       ifp->if_flags = IFF_BROADCAST | IFF_NOTRAILERS;
-
-       /* Now we can attach the interface. */
-
-/*     dprintf(("Attaching interface...\n"));*/
-       if_attach(ifp);
-       ether_ifattach(ifp, myaddr);
-
-       /* Finally, attach to bpf filter if it is present. */
-
-#if NBPFILTER > 0
-/*     dprintf(("Attaching to BPF...\n"));*/
-       bpfattach(&ifp->if_bpf, ifp, DLT_EN10MB, sizeof(struct ether_header));
-#endif
-
-       /* Should test the RAM */
-
-       ea_ramtest(sc);
-
-       printf("\n");
-/*     dprintf(("eaattach() finished.\n"));*/
-}
-
-
-/*
- * Test the RAM on the ethernet card.



Home | Main Index | Thread Index | Old Index