if_ze.c revision 1.10 1 1.10 lukem /* $NetBSD: if_ze.c,v 1.10 2003/07/15 02:15:01 lukem Exp $ */
2 1.1 ragge /*
3 1.1 ragge * Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
4 1.1 ragge *
5 1.1 ragge * Redistribution and use in source and binary forms, with or without
6 1.1 ragge * modification, are permitted provided that the following conditions
7 1.1 ragge * are met:
8 1.1 ragge * 1. Redistributions of source code must retain the above copyright
9 1.1 ragge * notice, this list of conditions and the following disclaimer.
10 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 ragge * notice, this list of conditions and the following disclaimer in the
12 1.1 ragge * documentation and/or other materials provided with the distribution.
13 1.1 ragge * 3. All advertising materials mentioning features or use of this software
14 1.1 ragge * must display the following acknowledgement:
15 1.1 ragge * This product includes software developed at Ludd, University of
16 1.1 ragge * Lule}, Sweden and its contributors.
17 1.1 ragge * 4. The name of the author may not be used to endorse or promote products
18 1.1 ragge * derived from this software without specific prior written permission
19 1.1 ragge *
20 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21 1.1 ragge * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22 1.1 ragge * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23 1.1 ragge * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24 1.1 ragge * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25 1.1 ragge * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1 ragge * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1 ragge * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1 ragge * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29 1.1 ragge * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 ragge */
31 1.10 lukem
32 1.10 lukem #include <sys/cdefs.h>
33 1.10 lukem __KERNEL_RCSID(0, "$NetBSD: if_ze.c,v 1.10 2003/07/15 02:15:01 lukem Exp $");
34 1.1 ragge
35 1.6 ragge #include "opt_cputype.h"
36 1.6 ragge
37 1.1 ragge #include <sys/param.h>
38 1.1 ragge #include <sys/socket.h>
39 1.1 ragge #include <sys/device.h>
40 1.1 ragge #include <sys/systm.h>
41 1.1 ragge #include <sys/sockio.h>
42 1.1 ragge
43 1.1 ragge #include <net/if.h>
44 1.1 ragge #include <net/if_ether.h>
45 1.1 ragge #include <net/if_dl.h>
46 1.1 ragge
47 1.1 ragge #include <netinet/in.h>
48 1.1 ragge #include <netinet/if_inarp.h>
49 1.1 ragge
50 1.1 ragge #if NBPFILTER > 0
51 1.1 ragge #include <net/bpf.h>
52 1.1 ragge #include <net/bpfdesc.h>
53 1.1 ragge #endif
54 1.1 ragge
55 1.1 ragge #include <machine/bus.h>
56 1.1 ragge #include <machine/nexus.h>
57 1.1 ragge #include <machine/cpu.h>
58 1.1 ragge #include <machine/scb.h>
59 1.4 ragge #include <machine/sid.h>
60 1.1 ragge
61 1.1 ragge #include <dev/ic/sgecreg.h>
62 1.1 ragge #include <dev/ic/sgecvar.h>
63 1.1 ragge
64 1.1 ragge #include "ioconf.h"
65 1.1 ragge /*
66 1.1 ragge * Adresses.
67 1.1 ragge */
68 1.1 ragge #define SGECADDR 0x20008000
69 1.1 ragge #define NISA_ROM 0x20084000
70 1.6 ragge #define NISA_ROM_VXT 0x200c4000
71 1.1 ragge #define SGECVEC 0x108
72 1.1 ragge
73 1.1 ragge static int zematch __P((struct device *, struct cfdata *, void *));
74 1.1 ragge static void zeattach __P((struct device *, struct device *, void *));
75 1.1 ragge
76 1.8 thorpej CFATTACH_DECL(ze_ibus, sizeof(struct ze_softc),
77 1.9 thorpej zematch, zeattach, NULL, NULL);
78 1.1 ragge
79 1.1 ragge /*
80 1.1 ragge * Check for present SGEC.
81 1.1 ragge */
82 1.1 ragge int
83 1.1 ragge zematch(parent, cf, aux)
84 1.1 ragge struct device *parent;
85 1.1 ragge struct cfdata *cf;
86 1.1 ragge void *aux;
87 1.1 ragge {
88 1.1 ragge struct bp_conf *bp = aux;
89 1.1 ragge
90 1.1 ragge /*
91 1.1 ragge * Should some more intelligent checking be done???
92 1.1 ragge */
93 1.1 ragge if (strcmp(bp->type, "sgec") == 0)
94 1.1 ragge return 1;
95 1.1 ragge return 0;
96 1.1 ragge }
97 1.1 ragge
98 1.1 ragge /*
99 1.1 ragge * Interface exists: make available by filling in network interface
100 1.1 ragge * record. System will initialize the interface when it is ready
101 1.1 ragge * to accept packets.
102 1.1 ragge */
103 1.1 ragge void
104 1.1 ragge zeattach(parent, self, aux)
105 1.1 ragge struct device *parent, *self;
106 1.1 ragge void *aux;
107 1.1 ragge {
108 1.1 ragge extern struct vax_bus_dma_tag vax_bus_dma_tag;
109 1.1 ragge struct ze_softc *sc = (struct ze_softc *)self;
110 1.6 ragge paddr_t nisarom;
111 1.1 ragge int *ea, i;
112 1.1 ragge
113 1.1 ragge /*
114 1.1 ragge * Map in SGEC registers.
115 1.1 ragge */
116 1.1 ragge sc->sc_ioh = vax_map_physmem(SGECADDR, 1);
117 1.1 ragge sc->sc_iot = 0; /* :-) */
118 1.1 ragge sc->sc_dmat = &vax_bus_dma_tag;
119 1.1 ragge
120 1.1 ragge sc->sc_intvec = SGECVEC;
121 1.1 ragge
122 1.1 ragge /*
123 1.1 ragge * Map in, read and release ethernet rom address.
124 1.1 ragge */
125 1.6 ragge nisarom = (vax_boardtype == VAX_BTYP_VXT ? NISA_ROM_VXT : NISA_ROM);
126 1.6 ragge ea = (int *)vax_map_physmem(nisarom, 1);
127 1.6 ragge for (i = 0; i < ETHER_ADDR_LEN; i++) {
128 1.4 ragge if (vax_boardtype == VAX_BTYP_660)
129 1.4 ragge sc->sc_enaddr[i] = (ea[i] >> 24) & 0377;
130 1.6 ragge #if VXT2000 || VAXANY
131 1.6 ragge else if (vax_boardtype == VAX_BTYP_VXT)
132 1.6 ragge sc->sc_enaddr[i] = ea[i] & 0377;
133 1.6 ragge #endif
134 1.4 ragge else
135 1.4 ragge sc->sc_enaddr[i] = (ea[i] >> 8) & 0377;
136 1.6 ragge }
137 1.1 ragge vax_unmap_physmem((vaddr_t)ea, 1);
138 1.1 ragge
139 1.6 ragge #if VXT2000 || VAXANY
140 1.6 ragge if (vax_boardtype == VAX_BTYP_VXT)
141 1.6 ragge scb_vecalloc(0x200, (void (*)(void *)) sgec_intr, sc,
142 1.6 ragge SCB_ISTACK, &sc->sc_intrcnt);
143 1.6 ragge else
144 1.6 ragge #endif
145 1.6 ragge scb_vecalloc(SGECVEC, (void (*)(void *)) sgec_intr, sc,
146 1.6 ragge SCB_ISTACK, &sc->sc_intrcnt);
147 1.1 ragge
148 1.1 ragge sgec_attach(sc);
149 1.1 ragge }
150