Annotation of sys/dev/tc/if_fta.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: if_fta.c,v 1.13 2007/04/12 17:05:20 miod Exp $ */
! 2: /* $NetBSD: if_fta.c,v 1.7 1996/10/22 21:37:26 cgd Exp $ */
! 3:
! 4: /*-
! 5: * Copyright (c) 1996 Matt Thomas <matt@3am-software.com>
! 6: * All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. The name of the author may not be used to endorse or promote products
! 14: * derived from this software without specific prior written permission
! 15: *
! 16: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 17: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 18: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 19: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 20: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 21: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 22: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 23: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 24: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 25: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 26: *
! 27: * Id: if_fta.c,v 1.3 1996/05/17 01:15:18 thomas Exp
! 28: *
! 29: */
! 30:
! 31: /*
! 32: * DEC TurboChannel FDDI Controller; code for BSD derived operating systems
! 33: *
! 34: * Written by Matt Thomas
! 35: *
! 36: * This module supports the DEC DEFTA TurboChannel FDDI Controller
! 37: */
! 38:
! 39:
! 40: #include <sys/param.h>
! 41: #include <sys/kernel.h>
! 42: #include <sys/mbuf.h>
! 43: #include <sys/protosw.h>
! 44: #include <sys/socket.h>
! 45: #include <sys/ioctl.h>
! 46: #include <sys/errno.h>
! 47: #include <sys/malloc.h>
! 48: #include <sys/device.h>
! 49:
! 50: #include <net/if.h>
! 51: #include <net/if_types.h>
! 52:
! 53: #ifdef INET
! 54: #include <netinet/in.h>
! 55: #include <netinet/if_ether.h>
! 56: #endif
! 57: #include <net/if_fddi.h>
! 58:
! 59: #include <uvm/uvm_extern.h>
! 60:
! 61: #include <dev/tc/tcvar.h>
! 62: #include <dev/ic/pdqvar.h>
! 63: #include <dev/ic/pdqreg.h>
! 64:
! 65: int pdq_tc_match(struct device *, void *, void *);
! 66: void pdq_tc_attach(struct device *, struct device *, void *);
! 67:
! 68: int
! 69: pdq_tc_match(parent, match, aux)
! 70: struct device *parent;
! 71: void *match;
! 72: void *aux;
! 73: {
! 74: struct tc_attach_args *ta = (struct tc_attach_args *) aux;
! 75:
! 76: if (strncmp("PMAF-F", ta->ta_modname, 6) == 0)
! 77: return (1);
! 78: return (0);
! 79: }
! 80:
! 81: void
! 82: pdq_tc_attach(parent, self, aux)
! 83: struct device *parent;
! 84: struct device *self;
! 85: void *aux;
! 86: {
! 87: pdq_softc_t * const sc = (pdq_softc_t *) self;
! 88: struct tc_attach_args * const ta = (struct tc_attach_args *) aux;
! 89:
! 90: /*
! 91: * NOTE: sc_bc is an alias for sc_csrtag and sc_membase is an
! 92: * alias for sc_csrhandle. sc_iobase is not used in this front-end.
! 93: */
! 94: sc->sc_csrtag = ta->ta_memt;
! 95: bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ);
! 96: sc->sc_if.if_flags = 0;
! 97: sc->sc_if.if_softc = sc;
! 98:
! 99: if (bus_space_map(sc->sc_csrtag, ta->ta_addr + PDQ_TC_CSR_OFFSET,
! 100: PDQ_TC_CSR_SPACE, 0, &sc->sc_csrhandle)) {
! 101: printf("\n%s: can't map card memory!\n", sc->sc_dev.dv_xname);
! 102: return;
! 103: }
! 104:
! 105: printf("\n");
! 106: sc->sc_pdq = pdq_initialize(sc->sc_csrtag, sc->sc_csrhandle,
! 107: sc->sc_if.if_xname, 0, (void *) sc, PDQ_DEFTA);
! 108: if (sc->sc_pdq == NULL) {
! 109: printf("%s: initialization failed\n", sc->sc_dev.dv_xname);
! 110: return;
! 111: }
! 112: bcopy((caddr_t) sc->sc_pdq->pdq_hwaddr.lanaddr_bytes,
! 113: sc->sc_arpcom.ac_enaddr, 6);
! 114: pdq_ifattach(sc, NULL);
! 115:
! 116: tc_intr_establish(parent, ta->ta_cookie, TC_IPL_NET,
! 117: (int (*)(void *)) pdq_interrupt, sc->sc_pdq);
! 118:
! 119: sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset,
! 120: sc->sc_pdq);
! 121: if (sc->sc_ats == NULL)
! 122: printf("%s: warning: couldn't establish shutdown hook\n",
! 123: self->dv_xname);
! 124: }
! 125:
! 126: struct cfattach fta_ca = {
! 127: sizeof(pdq_softc_t), pdq_tc_match, pdq_tc_attach
! 128: };
! 129:
! 130: struct cfdriver fta_cd = {
! 131: 0, "fta", DV_IFNET
! 132: };
CVSweb