if_ze.c revision 1.6 1 1.6 ragge /* $NetBSD: if_ze.c,v 1.6 2002/05/27 17:32:01 ragge 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.1 ragge
32 1.6 ragge #include "opt_cputype.h"
33 1.6 ragge
34 1.1 ragge #include <sys/param.h>
35 1.1 ragge #include <sys/socket.h>
36 1.1 ragge #include <sys/device.h>
37 1.1 ragge #include <sys/systm.h>
38 1.1 ragge #include <sys/sockio.h>
39 1.1 ragge
40 1.1 ragge #include <net/if.h>
41 1.1 ragge #include <net/if_ether.h>
42 1.1 ragge #include <net/if_dl.h>
43 1.1 ragge
44 1.1 ragge #include <netinet/in.h>
45 1.1 ragge #include <netinet/if_inarp.h>
46 1.1 ragge
47 1.1 ragge #if NBPFILTER > 0
48 1.1 ragge #include <net/bpf.h>
49 1.1 ragge #include <net/bpfdesc.h>
50 1.1 ragge #endif
51 1.1 ragge
52 1.1 ragge #include <machine/bus.h>
53 1.1 ragge #include <machine/nexus.h>
54 1.1 ragge #include <machine/cpu.h>
55 1.1 ragge #include <machine/scb.h>
56 1.4 ragge #include <machine/sid.h>
57 1.1 ragge
58 1.1 ragge #include <dev/ic/sgecreg.h>
59 1.1 ragge #include <dev/ic/sgecvar.h>
60 1.1 ragge
61 1.1 ragge #include "ioconf.h"
62 1.1 ragge /*
63 1.1 ragge * Adresses.
64 1.1 ragge */
65 1.1 ragge #define SGECADDR 0x20008000
66 1.1 ragge #define NISA_ROM 0x20084000
67 1.6 ragge #define NISA_ROM_VXT 0x200c4000
68 1.1 ragge #define SGECVEC 0x108
69 1.1 ragge
70 1.1 ragge static int zematch __P((struct device *, struct cfdata *, void *));
71 1.1 ragge static void zeattach __P((struct device *, struct device *, void *));
72 1.1 ragge
73 1.2 ragge struct cfattach ze_ibus_ca = {
74 1.1 ragge sizeof(struct ze_softc), zematch, zeattach
75 1.1 ragge };
76 1.1 ragge
77 1.1 ragge /*
78 1.1 ragge * Check for present SGEC.
79 1.1 ragge */
80 1.1 ragge int
81 1.1 ragge zematch(parent, cf, aux)
82 1.1 ragge struct device *parent;
83 1.1 ragge struct cfdata *cf;
84 1.1 ragge void *aux;
85 1.1 ragge {
86 1.1 ragge struct bp_conf *bp = aux;
87 1.1 ragge
88 1.1 ragge /*
89 1.1 ragge * Should some more intelligent checking be done???
90 1.1 ragge */
91 1.1 ragge if (strcmp(bp->type, "sgec") == 0)
92 1.1 ragge return 1;
93 1.1 ragge return 0;
94 1.1 ragge }
95 1.1 ragge
96 1.1 ragge /*
97 1.1 ragge * Interface exists: make available by filling in network interface
98 1.1 ragge * record. System will initialize the interface when it is ready
99 1.1 ragge * to accept packets.
100 1.1 ragge */
101 1.1 ragge void
102 1.1 ragge zeattach(parent, self, aux)
103 1.1 ragge struct device *parent, *self;
104 1.1 ragge void *aux;
105 1.1 ragge {
106 1.1 ragge extern struct vax_bus_dma_tag vax_bus_dma_tag;
107 1.1 ragge struct ze_softc *sc = (struct ze_softc *)self;
108 1.6 ragge paddr_t nisarom;
109 1.1 ragge int *ea, i;
110 1.1 ragge
111 1.1 ragge /*
112 1.1 ragge * Map in SGEC registers.
113 1.1 ragge */
114 1.1 ragge sc->sc_ioh = vax_map_physmem(SGECADDR, 1);
115 1.1 ragge sc->sc_iot = 0; /* :-) */
116 1.1 ragge sc->sc_dmat = &vax_bus_dma_tag;
117 1.1 ragge
118 1.1 ragge sc->sc_intvec = SGECVEC;
119 1.1 ragge
120 1.1 ragge /*
121 1.1 ragge * Map in, read and release ethernet rom address.
122 1.1 ragge */
123 1.6 ragge nisarom = (vax_boardtype == VAX_BTYP_VXT ? NISA_ROM_VXT : NISA_ROM);
124 1.6 ragge ea = (int *)vax_map_physmem(nisarom, 1);
125 1.6 ragge for (i = 0; i < ETHER_ADDR_LEN; i++) {
126 1.4 ragge if (vax_boardtype == VAX_BTYP_660)
127 1.4 ragge sc->sc_enaddr[i] = (ea[i] >> 24) & 0377;
128 1.6 ragge #if VXT2000 || VAXANY
129 1.6 ragge else if (vax_boardtype == VAX_BTYP_VXT)
130 1.6 ragge sc->sc_enaddr[i] = ea[i] & 0377;
131 1.6 ragge #endif
132 1.4 ragge else
133 1.4 ragge sc->sc_enaddr[i] = (ea[i] >> 8) & 0377;
134 1.6 ragge }
135 1.1 ragge vax_unmap_physmem((vaddr_t)ea, 1);
136 1.1 ragge
137 1.6 ragge #if VXT2000 || VAXANY
138 1.6 ragge if (vax_boardtype == VAX_BTYP_VXT)
139 1.6 ragge scb_vecalloc(0x200, (void (*)(void *)) sgec_intr, sc,
140 1.6 ragge SCB_ISTACK, &sc->sc_intrcnt);
141 1.6 ragge else
142 1.6 ragge #endif
143 1.6 ragge scb_vecalloc(SGECVEC, (void (*)(void *)) sgec_intr, sc,
144 1.6 ragge SCB_ISTACK, &sc->sc_intrcnt);
145 1.1 ragge
146 1.1 ragge sgec_attach(sc);
147 1.1 ragge }
148