2001-11-13 09:26:09 +03:00
|
|
|
/* $NetBSD: if_fta.c,v 1.19 2001/11/13 06:26:10 lukem Exp $ */
|
1996-05-20 04:20:39 +04:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1996 Matt Thomas <matt@3am-software.com>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
2001-06-13 14:45:57 +04:00
|
|
|
* derived from this software without specific prior written permission
|
1996-05-20 04:20:39 +04:00
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
1997-03-24 03:35:02 +03:00
|
|
|
* Id: if_fta.c,v 1.4 1997/03/21 13:45:45 thomas Exp
|
1996-05-20 04:20:39 +04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DEC TurboChannel FDDI Controller; code for BSD derived operating systems
|
|
|
|
*
|
|
|
|
* Written by Matt Thomas
|
|
|
|
*
|
|
|
|
* This module supports the DEC DEFTA TurboChannel FDDI Controller
|
|
|
|
*/
|
|
|
|
|
2001-11-13 09:26:09 +03:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__KERNEL_RCSID(0, "$NetBSD: if_fta.c,v 1.19 2001/11/13 06:26:10 lukem Exp $");
|
|
|
|
|
1998-07-05 04:51:04 +04:00
|
|
|
#include "opt_inet.h"
|
1996-05-20 04:20:39 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
1997-03-24 03:35:02 +03:00
|
|
|
#include <net/if_fddi.h>
|
1996-05-20 04:20:39 +04:00
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
1997-03-15 21:09:08 +03:00
|
|
|
#include <netinet/if_inarp.h>
|
1996-05-20 04:20:39 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <dev/tc/tcvar.h>
|
|
|
|
#include <dev/ic/pdqvar.h>
|
|
|
|
#include <dev/ic/pdqreg.h>
|
|
|
|
|
|
|
|
static int
|
|
|
|
pdq_tc_match(
|
|
|
|
struct device *parent,
|
1996-12-05 04:25:23 +03:00
|
|
|
struct cfdata *match,
|
1996-05-20 04:20:39 +04:00
|
|
|
void *aux)
|
|
|
|
{
|
|
|
|
struct tc_attach_args *ta = (struct tc_attach_args *) aux;
|
|
|
|
|
|
|
|
if (strncmp("PMAF-F", ta->ta_modname, 6) == 0)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pdq_tc_attach(
|
|
|
|
struct device * const parent,
|
|
|
|
struct device * const self,
|
|
|
|
void * const aux)
|
|
|
|
{
|
|
|
|
pdq_softc_t * const sc = (pdq_softc_t *) self;
|
|
|
|
struct tc_attach_args * const ta = (struct tc_attach_args *) aux;
|
|
|
|
|
1996-10-23 01:34:19 +04:00
|
|
|
/*
|
|
|
|
* NOTE: sc_bc is an alias for sc_csrtag and sc_membase is an
|
|
|
|
* alias for sc_csrhandle. sc_iobase is not used in this front-end.
|
|
|
|
*/
|
1998-05-22 00:44:02 +04:00
|
|
|
sc->sc_dmatag = ta->ta_dmat;
|
1996-10-23 01:34:19 +04:00
|
|
|
sc->sc_csrtag = ta->ta_memt;
|
1996-05-20 04:20:39 +04:00
|
|
|
bcopy(sc->sc_dev.dv_xname, sc->sc_if.if_xname, IFNAMSIZ);
|
|
|
|
sc->sc_if.if_flags = 0;
|
|
|
|
sc->sc_if.if_softc = sc;
|
|
|
|
|
1996-10-23 01:34:19 +04:00
|
|
|
if (bus_space_map(sc->sc_csrtag, ta->ta_addr + PDQ_TC_CSR_OFFSET,
|
1997-03-24 03:35:02 +03:00
|
|
|
PDQ_TC_CSR_SPACE, 0, &sc->sc_membase)) {
|
|
|
|
printf("\n%s: can't map card memory!\n", sc->sc_dev.dv_xname);
|
1996-05-20 04:20:39 +04:00
|
|
|
return;
|
1996-05-20 19:52:32 +04:00
|
|
|
}
|
1996-05-20 04:20:39 +04:00
|
|
|
|
1997-03-24 03:35:02 +03:00
|
|
|
sc->sc_pdq = pdq_initialize(sc->sc_csrtag, sc->sc_membase,
|
1996-05-20 04:20:39 +04:00
|
|
|
sc->sc_if.if_xname, 0,
|
|
|
|
(void *) sc, PDQ_DEFTA);
|
|
|
|
if (sc->sc_pdq == NULL) {
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: initialization failed\n", sc->sc_dev.dv_xname);
|
1996-05-20 04:20:39 +04:00
|
|
|
return;
|
|
|
|
}
|
1997-03-15 21:09:08 +03:00
|
|
|
|
1996-05-20 04:20:39 +04:00
|
|
|
pdq_ifattach(sc, NULL);
|
|
|
|
|
1996-05-20 05:31:07 +04:00
|
|
|
tc_intr_establish(parent, ta->ta_cookie, TC_IPL_NET,
|
1996-05-20 04:20:39 +04:00
|
|
|
(int (*)(void *)) pdq_interrupt, sc->sc_pdq);
|
|
|
|
|
|
|
|
sc->sc_ats = shutdownhook_establish((void (*)(void *)) pdq_hwreset, sc->sc_pdq);
|
|
|
|
if (sc->sc_ats == NULL)
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: warning: couldn't establish shutdown hook\n", self->dv_xname);
|
1996-05-20 04:20:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct cfattach fta_ca = { sizeof(pdq_softc_t), pdq_tc_match, pdq_tc_attach };
|