This source file includes following definitions.
- ne_isa_match
- ne_isa_attach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41 #include "bpfilter.h"
42
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/mbuf.h>
46 #include <sys/socket.h>
47 #include <sys/ioctl.h>
48 #include <sys/errno.h>
49 #include <sys/syslog.h>
50 #include <sys/selinfo.h>
51 #include <sys/device.h>
52
53 #include <net/if.h>
54 #include <net/if_dl.h>
55 #include <net/if_media.h>
56
57 #ifdef INET
58 #include <netinet/in.h>
59 #include <netinet/in_systm.h>
60 #include <netinet/in_var.h>
61 #include <netinet/ip.h>
62 #include <netinet/if_ether.h>
63 #endif
64
65 #if NBPFILTER > 0
66 #include <net/bpf.h>
67 #endif
68
69 #include <machine/intr.h>
70 #include <machine/bus.h>
71
72 #include <dev/ic/dp8390reg.h>
73 #include <dev/ic/dp8390var.h>
74
75 #include <dev/ic/ne2000reg.h>
76 #include <dev/ic/ne2000var.h>
77
78 #include <dev/ic/rtl80x9reg.h>
79 #include <dev/ic/rtl80x9var.h>
80
81 #include <dev/isa/isavar.h>
82
83 int ne_isa_match(struct device *, void *, void *);
84 void ne_isa_attach(struct device *, struct device *, void *);
85
86 struct ne_isa_softc {
87 struct ne2000_softc sc_ne2000;
88
89
90 void *sc_ih;
91 };
92
93 struct cfattach ne_isa_ca = {
94 sizeof(struct ne_isa_softc), ne_isa_match, ne_isa_attach
95 };
96
97 int
98 ne_isa_match(struct device *parent, void *match, void *aux)
99 {
100 struct ne_isa_softc *isc = match;
101 struct ne2000_softc *nsc = &isc->sc_ne2000;
102 struct dp8390_softc *dsc = &nsc->sc_dp8390;
103 struct isa_attach_args *ia = aux;
104 bus_space_tag_t nict = ia->ia_iot;
105 bus_space_handle_t nich;
106 bus_space_tag_t asict;
107 bus_space_handle_t asich;
108
109
110 if (ia->ia_irq == -1 )
111 return (0);
112 if (ia->ia_iobase == -1 )
113 return (0);
114
115
116 if ((ia->ia_iobase & 0x1f) != 0)
117 return (0);
118
119
120 if (bus_space_map(nict, ia->ia_iobase, NE2000_NPORTS, 0, &nich))
121 return (0);
122
123 asict = nict;
124 if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET,
125 NE2000_ASIC_NPORTS, &asich))
126 goto out;
127
128 dsc->sc_regt = nict;
129 dsc->sc_regh = nich;
130
131 nsc->sc_asict = asict;
132 nsc->sc_asich = asich;
133
134
135 nsc->sc_type = ne2000_detect(nsc);
136
137 if (nsc->sc_type)
138 ia->ia_iosize = NE2000_NPORTS;
139
140 out:
141 bus_space_unmap(nict, nich, NE2000_NPORTS);
142 return (nsc->sc_type);
143 }
144
145 void
146 ne_isa_attach(struct device *parent, struct device *self, void *aux)
147 {
148 struct ne_isa_softc *isc = (struct ne_isa_softc *)self;
149 struct ne2000_softc *nsc = &isc->sc_ne2000;
150 struct dp8390_softc *dsc = &nsc->sc_dp8390;
151 struct isa_attach_args *ia = aux;
152 bus_space_tag_t nict = ia->ia_iot;
153 bus_space_handle_t nich;
154 bus_space_tag_t asict = nict;
155 bus_space_handle_t asich;
156 const char *typestr;
157
158
159 if (bus_space_map(nict, ia->ia_iobase, NE2000_NPORTS, 0, &nich)) {
160 printf("%s: can't map i/o space\n", dsc->sc_dev.dv_xname);
161 return;
162 }
163
164 if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET,
165 NE2000_ASIC_NPORTS, &asich)) {
166 printf("%s: can't subregion i/o space\n", dsc->sc_dev.dv_xname);
167 return;
168 }
169
170 dsc->sc_regt = nict;
171 dsc->sc_regh = nich;
172
173 nsc->sc_asict = asict;
174 nsc->sc_asich = asich;
175
176 switch (nsc->sc_type) {
177 case NE2000_TYPE_NE1000:
178 typestr = "NE1000";
179 break;
180
181 case NE2000_TYPE_NE2000:
182 typestr = "NE2000";
183
184
185
186 bus_space_write_1(nict, nich, ED_P0_CR,
187 ED_CR_PAGE_0 | ED_CR_STP);
188 if (bus_space_read_1(nict, nich, NERTL_RTL0_8019ID0) ==
189 RTL0_8019ID0 &&
190 bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) ==
191 RTL0_8019ID1) {
192 typestr = "NE2000 (RTL8019)";
193 dsc->sc_mediachange = rtl80x9_mediachange;
194 dsc->sc_mediastatus = rtl80x9_mediastatus;
195 dsc->init_card = rtl80x9_init_card;
196 dsc->sc_media_init = rtl80x9_media_init;
197 }
198 break;
199
200 default:
201 printf(": where did the card go?!\n");
202 return;
203 }
204
205 printf(", %s", typestr);
206
207
208 dsc->sc_enabled = 1;
209
210
211
212
213
214 ne2000_attach(nsc, NULL);
215
216
217 isc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
218 IPL_NET, dp8390_intr, dsc, dsc->sc_dev.dv_xname);
219 if (isc->sc_ih == NULL)
220 printf(": couldn't establish interrupt handler\n");
221 }