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