diff options
author | denny <denny@cvs.openbsd.org> | 1997-06-18 02:59:31 +0000 |
---|---|---|
committer | denny <denny@cvs.openbsd.org> | 1997-06-18 02:59:31 +0000 |
commit | 4873820d037822cb9e8e5d7f6c6e728e7b24bf7a (patch) | |
tree | 279b2a9d9e836e677aa7df665b606a42a11d8806 /sys/arch/mac68k/dev/if_sn_obio.c | |
parent | 3447cebe96ec85236b4f6971ada0a2d02a6e10f0 (diff) |
Make if_sn.c far more MI, eventually share with pica.
sonic_get is faster and simpler.
sn_ioctl works like other current ether drivers now.
Sync up with netbsd to ease maintenance; incorporate some "gratuitous" formatting changes so I won't have to do two totally seperate mods each time.
Diffstat (limited to 'sys/arch/mac68k/dev/if_sn_obio.c')
-rw-r--r-- | sys/arch/mac68k/dev/if_sn_obio.c | 107 |
1 files changed, 56 insertions, 51 deletions
diff --git a/sys/arch/mac68k/dev/if_sn_obio.c b/sys/arch/mac68k/dev/if_sn_obio.c index 09df12eebe5..14da748eda5 100644 --- a/sys/arch/mac68k/dev/if_sn_obio.c +++ b/sys/arch/mac68k/dev/if_sn_obio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sn_obio.c,v 1.13 1997/04/22 13:37:56 briggs Exp $ */ +/* $NetBSD: if_sn_obio.c,v 1.9 1997/04/22 20:56:15 scottr Exp $ */ /* * Copyright (C) 1997 Allen Briggs @@ -39,7 +39,6 @@ #include <sys/systm.h> #include <net/if.h> - #include <netinet/in.h> #include <netinet/if_ether.h> @@ -56,17 +55,17 @@ static int sn_obio_match __P((struct device *, void *, void *)); static void sn_obio_attach __P((struct device *, struct device *, void *)); -static int sn_obio_getaddr __P((struct sn_softc *)); -static int sn_obio_getaddr_kludge __P((struct sn_softc *)); +static int sn_obio_getaddr __P((struct sn_softc *, u_int8_t *)); +static int sn_obio_getaddr_kludge __P((struct sn_softc *, u_int8_t *)); struct cfattach sn_obio_ca = { sizeof(struct sn_softc), sn_obio_match, sn_obio_attach }; static int -sn_obio_match(parent, vcf, aux) +sn_obio_match(parent, cf, aux) struct device *parent; - void *vcf; + void *cf; void *aux; { if (mac68k_machine.sonic) @@ -83,33 +82,43 @@ sn_obio_attach(parent, self, aux) struct device *parent, *self; void *aux; { - struct obio_attach_args *oa = (struct obio_attach_args *) aux; - struct sn_softc *sc = (void *)self; + struct obio_attach_args *oa = (struct obio_attach_args *)aux; + struct sn_softc *sc = (void *)self; + u_int8_t myaddr[ETHER_ADDR_LEN]; int i; - sc->snr_dcr = DCR_WAIT0 | DCR_DMABLOCK | - DCR_RFT16 | DCR_TFT16; + sc->snr_dcr = DCR_WAIT0 | DCR_DMABLOCK | DCR_RFT16 | DCR_TFT16; sc->snr_dcr2 = 0; switch (current_mac_model->machineid) { - case MACH_MACQ700: case MACH_MACQ900: case MACH_MACQ950: - case MACH_MACQ800: case MACH_MACQ650: case MACH_MACC650: - case MACH_MACC610: case MACH_MACQ610: - sc->snr_dcr |= DCR_EXBUS | DCR_DW32; + case MACH_MACC610: + case MACH_MACC650: + case MACH_MACQ610: + case MACH_MACQ650: + case MACH_MACQ700: + case MACH_MACQ800: + case MACH_MACQ900: + case MACH_MACQ950: + sc->snr_dcr |= DCR_EXBUS; sc->bitmode = 1; break; case MACH_MACPB500: - sc->snr_dcr |= DCR_SYNC | DCR_LBR | DCR_DW16; - sc->bitmode = 0; + sc->snr_dcr |= DCR_SYNC | DCR_LBR; + sc->bitmode = 0; /* 16 bit interface */ break; - } + + default: + printf(": unsupported machine type\n"); + return; + } sc->sc_regt = oa->oa_tag; - if (bus_space_map(sc->sc_regt, SONIC_REG_BASE, SN_REGSIZE, - 0, &sc->sc_regh)) { - panic("failed to map space for SONIC regs.\n"); + if (bus_space_map(sc->sc_regt, + SONIC_REG_BASE, SN_REGSIZE, 0, &sc->sc_regh)) { + printf(": failed to map space for SONIC regs.\n"); + return; } sc->slotno = 9; @@ -119,17 +128,15 @@ sn_obio_attach(parent, self, aux) sc->sc_reg_map[i] = (bus_size_t)((i * 4) + 2); } - if (sn_obio_getaddr(sc)) { - printf(": Failed to get MAC address. Trying kludge.\n"); - if (sn_obio_getaddr_kludge(sc)) { - printf("Kludge failed, too. Attachment failed.\n"); - bus_space_unmap(sc->sc_regt, sc->sc_regh, SN_REGSIZE); - return; - } + if (sn_obio_getaddr(sc, myaddr) && + sn_obio_getaddr_kludge(sc, myaddr)) { /* XXX kludge for PB */ + printf(": failed to get MAC address.\n"); + bus_space_unmap(sc->sc_regt, sc->sc_regh, SN_REGSIZE); + return; } /* snsetup returns 1 if something fails */ - if (snsetup(sc)) { + if (snsetup(sc, myaddr)) { bus_space_unmap(sc->sc_regt, sc->sc_regh, SN_REGSIZE); return; } @@ -138,21 +145,24 @@ sn_obio_attach(parent, self, aux) } static int -sn_obio_getaddr(sc) +sn_obio_getaddr(sc, lladdr) struct sn_softc *sc; + u_int8_t *lladdr; { - bus_space_handle_t bsh; + bus_space_handle_t bsh; if (bus_space_map(sc->sc_regt, SONIC_PROM_BASE, NBPG, 0, &bsh)) { - panic("failed to map space to read SONIC address.\n"); + printf(": failed to map space to read SONIC address.\n%s", + sc->sc_dev.dv_xname); + return (-1); } if (!bus_probe(sc->sc_regt, bsh, 0, 1)) { bus_space_unmap(sc->sc_regt, bsh, NBPG); - return -1; + return (-1); } - sn_get_enaddr(sc->sc_regt, bsh, 0, sc->sc_arpcom.ac_enaddr); + sn_get_enaddr(sc->sc_regt, bsh, 0, lladdr); bus_space_unmap(sc->sc_regt, bsh, NBPG); @@ -164,49 +174,44 @@ sn_obio_getaddr(sc) * when we can properly get the MAC address on the PBs. */ static int -sn_obio_getaddr_kludge(sc) +sn_obio_getaddr_kludge(sc, lladdr) struct sn_softc *sc; + u_int8_t *lladdr; { - int i, ors=0; + int i, ors = 0; /* Shut down NIC */ - NIC_PUT(sc, SNR_CR, CR_STP); - wbflush(); NIC_PUT(sc, SNR_CR, CR_RST); wbflush(); - NIC_PUT(sc, SNR_IMR, 0); - wbflush(); - NIC_PUT(sc, SNR_ISR, ISR_ALL); - wbflush(); - NIC_PUT(sc, SNR_CR, CR_RST); - wbflush(); NIC_PUT(sc, SNR_CEP, 15); /* For some reason, Apple fills top first. */ wbflush(); i = NIC_GET(sc, SNR_CAP2); wbflush(); ors |= i; - sc->sc_enaddr[5] = i >> 8; - sc->sc_enaddr[4] = i; + lladdr[5] = i >> 8; + lladdr[4] = i; i = NIC_GET(sc, SNR_CAP1); wbflush(); ors |= i; - sc->sc_enaddr[3] = i >> 8; - sc->sc_enaddr[2] = i; + lladdr[3] = i >> 8; + lladdr[2] = i; i = NIC_GET(sc, SNR_CAP0); wbflush(); ors |= i; - sc->sc_enaddr[1] = i >> 8; - sc->sc_enaddr[0] = i; + lladdr[1] = i >> 8; + lladdr[0] = i; NIC_PUT(sc, SNR_CR, 0); wbflush(); - if (ors == 0) return -1; - return (0); + if (ors == 0) + return -1; + + return 0; } |