This source file includes following definitions.
- ne_isapnp_match
- ne_isapnp_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 #include <dev/isa/isapnpreg.h>
84
85 static int ne_isapnp_match(struct device *, void *, void *);
86 static void ne_isapnp_attach(struct device *, struct device *, void *);
87
88 struct ne_isapnp_softc {
89 struct ne2000_softc sc_ne2000;
90
91
92 void *sc_ih;
93 };
94
95 struct cfattach ne_isapnp_ca = {
96 sizeof(struct ne_isapnp_softc), ne_isapnp_match, ne_isapnp_attach
97 };
98
99 static int
100 ne_isapnp_match(struct device *parent, void *match, void *aux)
101 {
102 return (1);
103 }
104
105 static void
106 ne_isapnp_attach(struct device *parent, struct device *self, void *aux)
107 {
108 struct ne_isapnp_softc * const isc = (struct ne_isapnp_softc *)self;
109 struct ne2000_softc * const nsc = &isc->sc_ne2000;
110 struct dp8390_softc * const dsc = &nsc->sc_dp8390;
111 struct isa_attach_args * const ipa = aux;
112 bus_space_tag_t nict;
113 bus_space_handle_t nich;
114 bus_space_tag_t asict;
115 bus_space_handle_t asich;
116 const char *typestr;
117 int netype;
118
119 nict = ipa->ia_iot;
120 nich = ipa->ipa_io[0].h;
121
122 asict = nict;
123
124 if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET,
125 NE2000_ASIC_NPORTS, &asich)) {
126 printf("%s: can't subregion i/o space\n", dsc->sc_dev.dv_xname);
127 return;
128 }
129
130 dsc->sc_regt = nict;
131 dsc->sc_regh = nich;
132
133 nsc->sc_asict = asict;
134 nsc->sc_asich = asich;
135
136
137
138
139
140 netype = ne2000_detect(nsc);
141 switch (netype) {
142 case NE2000_TYPE_NE1000:
143 typestr = "NE1000";
144 break;
145
146 case NE2000_TYPE_NE2000:
147 typestr = "NE2000";
148
149
150
151 bus_space_write_1(nict, nich, ED_P0_CR,
152 ED_CR_PAGE_0 | ED_CR_STP);
153 if (bus_space_read_1(nict, nich, NERTL_RTL0_8019ID0) ==
154 RTL0_8019ID0 &&
155 bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) ==
156 RTL0_8019ID1) {
157 typestr = "NE2000 (RTL8019)";
158 dsc->sc_mediachange = rtl80x9_mediachange;
159 dsc->sc_mediastatus = rtl80x9_mediastatus;
160 dsc->init_card = rtl80x9_init_card;
161 dsc->sc_media_init = rtl80x9_media_init;
162 }
163 break;
164
165 default:
166 printf(": where did the card go?!\n");
167 return;
168 }
169
170 printf(": %s", typestr);
171
172
173 dsc->sc_enabled = 1;
174
175
176
177
178
179 ne2000_attach(nsc, NULL);
180
181
182 isc->sc_ih = isa_intr_establish(ipa->ia_ic, ipa->ipa_irq[0].num,
183 IST_EDGE, IPL_NET, dp8390_intr, dsc,
184 dsc->sc_dev.dv_xname);
185 if (isc->sc_ih == NULL)
186 printf(": couldn't establish interrupt handler\n");
187 }