if_eg.c revision 1.100 1 1.100 thorpej /* $NetBSD: if_eg.c,v 1.100 2022/09/17 16:48:33 thorpej Exp $ */
2 1.4 cgd
3 1.1 deraadt /*
4 1.1 deraadt * Copyright (c) 1993 Dean Huxley <dean (at) fsa.ca>
5 1.1 deraadt * All rights reserved.
6 1.1 deraadt *
7 1.1 deraadt * Redistribution and use in source and binary forms, with or without
8 1.1 deraadt * modification, are permitted provided that the following conditions
9 1.1 deraadt * are met:
10 1.1 deraadt * 1. Redistributions of source code must retain the above copyright
11 1.1 deraadt * notice, this list of conditions and the following disclaimer.
12 1.1 deraadt * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 deraadt * notice, this list of conditions and the following disclaimer in the
14 1.1 deraadt * documentation and/or other materials provided with the distribution.
15 1.1 deraadt * 3. All advertising materials mentioning features or use of this software
16 1.1 deraadt * must display the following acknowledgement:
17 1.1 deraadt * This product includes software developed by Dean Huxley.
18 1.1 deraadt * 4. The name of Dean Huxley may not be used to endorse or promote products
19 1.1 deraadt * derived from this software without specific prior written permission.
20 1.1 deraadt *
21 1.1 deraadt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 deraadt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 deraadt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 deraadt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 deraadt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 deraadt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 deraadt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 deraadt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 deraadt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 deraadt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.22 hpeyerl */
32 1.22 hpeyerl /*
33 1.22 hpeyerl * Support for 3Com 3c505 Etherlink+ card.
34 1.1 deraadt */
35 1.1 deraadt
36 1.57 thorpej /*
37 1.57 thorpej * To do:
38 1.1 deraadt * - multicast
39 1.1 deraadt * - promiscuous
40 1.1 deraadt */
41 1.55 lukem
42 1.55 lukem #include <sys/cdefs.h>
43 1.100 thorpej __KERNEL_RCSID(0, "$NetBSD: if_eg.c,v 1.100 2022/09/17 16:48:33 thorpej Exp $");
44 1.55 lukem
45 1.42 jonathan #include "opt_inet.h"
46 1.1 deraadt
47 1.1 deraadt #include <sys/param.h>
48 1.31 thorpej #include <sys/systm.h>
49 1.98 thorpej #include <sys/kmem.h>
50 1.1 deraadt #include <sys/mbuf.h>
51 1.1 deraadt #include <sys/socket.h>
52 1.1 deraadt #include <sys/ioctl.h>
53 1.1 deraadt #include <sys/errno.h>
54 1.1 deraadt #include <sys/syslog.h>
55 1.1 deraadt #include <sys/select.h>
56 1.1 deraadt #include <sys/device.h>
57 1.88 riastrad #include <sys/rndsource.h>
58 1.1 deraadt
59 1.1 deraadt #include <net/if.h>
60 1.1 deraadt #include <net/if_dl.h>
61 1.1 deraadt #include <net/if_types.h>
62 1.93 msaitoh #include <net/bpf.h>
63 1.33 is
64 1.33 is #include <net/if_ether.h>
65 1.1 deraadt
66 1.1 deraadt #ifdef INET
67 1.1 deraadt #include <netinet/in.h>
68 1.1 deraadt #include <netinet/in_systm.h>
69 1.1 deraadt #include <netinet/in_var.h>
70 1.1 deraadt #include <netinet/ip.h>
71 1.33 is #include <netinet/if_inarp.h>
72 1.1 deraadt #endif
73 1.1 deraadt
74 1.73 ad #include <sys/cpu.h>
75 1.73 ad #include <sys/intr.h>
76 1.73 ad #include <sys/bus.h>
77 1.1 deraadt
78 1.12 cgd #include <dev/isa/isavar.h>
79 1.10 cgd #include <dev/isa/if_egreg.h>
80 1.10 cgd #include <dev/isa/elink.h>
81 1.1 deraadt
82 1.1 deraadt /* for debugging convenience */
83 1.1 deraadt #ifdef EGDEBUG
84 1.30 christos #define DPRINTF(x) printf x
85 1.1 deraadt #else
86 1.29 christos #define DPRINTF(x)
87 1.1 deraadt #endif
88 1.1 deraadt
89 1.1 deraadt #define EG_INLEN 10
90 1.1 deraadt #define EG_BUFLEN 0x0670
91 1.1 deraadt
92 1.40 drochner #define EG_PCBLEN 64
93 1.40 drochner
94 1.1 deraadt /*
95 1.1 deraadt * Ethernet software status per interface.
96 1.1 deraadt */
97 1.1 deraadt struct eg_softc {
98 1.85 chs device_t sc_dev;
99 1.12 cgd void *sc_ih;
100 1.33 is struct ethercom sc_ethercom; /* Ethernet common part */
101 1.32 thorpej bus_space_tag_t sc_iot; /* bus space identifier */
102 1.32 thorpej bus_space_handle_t sc_ioh; /* i/o handle */
103 1.100 thorpej uint8_t eg_rom_major; /* Cards ROM version (major number) */
104 1.100 thorpej uint8_t eg_rom_minor; /* Cards ROM version (minor number) */
105 1.27 thorpej short eg_ram; /* Amount of RAM on the card */
106 1.100 thorpej uint8_t eg_pcb[EG_PCBLEN]; /* Primary Command Block buffer */
107 1.100 thorpej uint8_t eg_incount; /* Number of buffers currently used */
108 1.72 christos void * eg_inbuf; /* Incoming packet buffer */
109 1.72 christos void * eg_outbuf; /* Outgoing packet buffer */
110 1.37 explorer
111 1.83 tls krndsource_t rnd_source;
112 1.1 deraadt };
113 1.1 deraadt
114 1.99 thorpej static int egprobe(device_t, cfdata_t, void *);
115 1.99 thorpej static void egattach(device_t, device_t, void *);
116 1.1 deraadt
117 1.85 chs CFATTACH_DECL_NEW(eg, sizeof(struct eg_softc),
118 1.60 thorpej egprobe, egattach, NULL, NULL);
119 1.1 deraadt
120 1.99 thorpej static int egintr(void *);
121 1.99 thorpej static void eginit(struct eg_softc *);
122 1.99 thorpej static int egioctl(struct ifnet *, u_long, void *);
123 1.99 thorpej static void egrecv(struct eg_softc *);
124 1.99 thorpej static void egstart(struct ifnet *);
125 1.99 thorpej static void egwatchdog(struct ifnet *);
126 1.99 thorpej static void egreset(struct eg_softc *);
127 1.99 thorpej static void egread(struct eg_softc *, void *, int);
128 1.99 thorpej static struct mbuf *egget(struct eg_softc *, void *, int);
129 1.99 thorpej static void egstop(struct eg_softc *);
130 1.64 perry
131 1.100 thorpej static inline void egprintpcb(uint8_t *);
132 1.100 thorpej static int egoutPCB(bus_space_tag_t, bus_space_handle_t, uint8_t);
133 1.100 thorpej static int egreadPCBstat(bus_space_tag_t, bus_space_handle_t, uint8_t);
134 1.64 perry static int egreadPCBready(bus_space_tag_t, bus_space_handle_t);
135 1.100 thorpej static int egwritePCB(bus_space_tag_t, bus_space_handle_t, uint8_t *);
136 1.100 thorpej static int egreadPCB(bus_space_tag_t, bus_space_handle_t, uint8_t *);
137 1.31 thorpej
138 1.1 deraadt /*
139 1.1 deraadt * Support stuff
140 1.1 deraadt */
141 1.65 perry
142 1.1 deraadt static inline void
143 1.100 thorpej egprintpcb(uint8_t *pcb)
144 1.1 deraadt {
145 1.1 deraadt int i;
146 1.65 perry
147 1.40 drochner for (i = 0; i < pcb[1] + 2; i++)
148 1.40 drochner DPRINTF(("pcb[%2d] = %x\n", i, pcb[i]));
149 1.1 deraadt }
150 1.1 deraadt
151 1.1 deraadt static int
152 1.100 thorpej egoutPCB(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t b)
153 1.1 deraadt {
154 1.1 deraadt int i;
155 1.1 deraadt
156 1.1 deraadt for (i=0; i < 4000; i++) {
157 1.32 thorpej if (bus_space_read_1(iot, ioh, EG_STATUS) & EG_STAT_HCRE) {
158 1.32 thorpej bus_space_write_1(iot, ioh, EG_COMMAND, b);
159 1.1 deraadt return 0;
160 1.1 deraadt }
161 1.1 deraadt delay(10);
162 1.1 deraadt }
163 1.29 christos DPRINTF(("egoutPCB failed\n"));
164 1.1 deraadt return 1;
165 1.1 deraadt }
166 1.65 perry
167 1.1 deraadt static int
168 1.100 thorpej egreadPCBstat(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t statb)
169 1.1 deraadt {
170 1.1 deraadt int i;
171 1.1 deraadt
172 1.1 deraadt for (i=0; i < 5000; i++) {
173 1.32 thorpej if ((bus_space_read_1(iot, ioh, EG_STATUS) &
174 1.65 perry EG_PCB_STAT) != EG_PCB_NULL)
175 1.1 deraadt break;
176 1.1 deraadt delay(10);
177 1.1 deraadt }
178 1.65 perry if ((bus_space_read_1(iot, ioh, EG_STATUS) & EG_PCB_STAT) == statb)
179 1.1 deraadt return 0;
180 1.1 deraadt return 1;
181 1.1 deraadt }
182 1.1 deraadt
183 1.1 deraadt static int
184 1.78 dsl egreadPCBready(bus_space_tag_t iot, bus_space_handle_t ioh)
185 1.1 deraadt {
186 1.1 deraadt int i;
187 1.1 deraadt
188 1.1 deraadt for (i=0; i < 10000; i++) {
189 1.32 thorpej if (bus_space_read_1(iot, ioh, EG_STATUS) & EG_STAT_ACRF)
190 1.1 deraadt return 0;
191 1.1 deraadt delay(5);
192 1.1 deraadt }
193 1.29 christos DPRINTF(("PCB read not ready\n"));
194 1.1 deraadt return 1;
195 1.1 deraadt }
196 1.65 perry
197 1.1 deraadt static int
198 1.100 thorpej egwritePCB(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t *pcb)
199 1.1 deraadt {
200 1.1 deraadt int i;
201 1.100 thorpej uint8_t len;
202 1.1 deraadt
203 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL,
204 1.32 thorpej (bus_space_read_1(iot, ioh, EG_CONTROL) & ~EG_PCB_STAT) | EG_PCB_NULL);
205 1.1 deraadt
206 1.40 drochner len = pcb[1] + 2;
207 1.1 deraadt for (i = 0; i < len; i++)
208 1.40 drochner egoutPCB(iot, ioh, pcb[i]);
209 1.27 thorpej
210 1.1 deraadt for (i=0; i < 4000; i++) {
211 1.32 thorpej if (bus_space_read_1(iot, ioh, EG_STATUS) & EG_STAT_HCRE)
212 1.1 deraadt break;
213 1.1 deraadt delay(10);
214 1.1 deraadt }
215 1.17 mycroft
216 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL,
217 1.32 thorpej (bus_space_read_1(iot, ioh, EG_CONTROL) & ~EG_PCB_STAT) | EG_PCB_DONE);
218 1.17 mycroft
219 1.40 drochner egoutPCB(iot, ioh, len);
220 1.1 deraadt
221 1.40 drochner if (egreadPCBstat(iot, ioh, EG_PCB_ACCEPT))
222 1.1 deraadt return 1;
223 1.1 deraadt return 0;
224 1.65 perry }
225 1.65 perry
226 1.1 deraadt static int
227 1.100 thorpej egreadPCB(bus_space_tag_t iot, bus_space_handle_t ioh, uint8_t *pcb)
228 1.1 deraadt {
229 1.1 deraadt int i;
230 1.27 thorpej
231 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL,
232 1.32 thorpej (bus_space_read_1(iot, ioh, EG_CONTROL) & ~EG_PCB_STAT) | EG_PCB_NULL);
233 1.1 deraadt
234 1.53 thorpej memset(pcb, 0, EG_PCBLEN);
235 1.1 deraadt
236 1.40 drochner if (egreadPCBready(iot, ioh))
237 1.1 deraadt return 1;
238 1.1 deraadt
239 1.40 drochner pcb[0] = bus_space_read_1(iot, ioh, EG_COMMAND);
240 1.27 thorpej
241 1.40 drochner if (egreadPCBready(iot, ioh))
242 1.1 deraadt return 1;
243 1.1 deraadt
244 1.40 drochner pcb[1] = bus_space_read_1(iot, ioh, EG_COMMAND);
245 1.1 deraadt
246 1.40 drochner if (pcb[1] > 62) {
247 1.40 drochner DPRINTF(("len %d too large\n", pcb[1]));
248 1.1 deraadt return 1;
249 1.1 deraadt }
250 1.27 thorpej
251 1.40 drochner for (i = 0; i < pcb[1]; i++) {
252 1.40 drochner if (egreadPCBready(iot, ioh))
253 1.1 deraadt return 1;
254 1.40 drochner pcb[2+i] = bus_space_read_1(iot, ioh, EG_COMMAND);
255 1.1 deraadt }
256 1.40 drochner if (egreadPCBready(iot, ioh))
257 1.1 deraadt return 1;
258 1.40 drochner if (egreadPCBstat(iot, ioh, EG_PCB_DONE))
259 1.1 deraadt return 1;
260 1.62 simonb if (bus_space_read_1(iot, ioh, EG_COMMAND) != pcb[1] + 2) {
261 1.1 deraadt return 1;
262 1.1 deraadt }
263 1.17 mycroft
264 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL,
265 1.32 thorpej (bus_space_read_1(iot, ioh, EG_CONTROL) &
266 1.27 thorpej ~EG_PCB_STAT) | EG_PCB_ACCEPT);
267 1.17 mycroft
268 1.1 deraadt return 0;
269 1.65 perry }
270 1.1 deraadt
271 1.1 deraadt /*
272 1.1 deraadt * Real stuff
273 1.1 deraadt */
274 1.1 deraadt
275 1.99 thorpej static int
276 1.80 cegger egprobe(device_t parent, cfdata_t match, void *aux)
277 1.1 deraadt {
278 1.1 deraadt struct isa_attach_args *ia = aux;
279 1.32 thorpej bus_space_tag_t iot = ia->ia_iot;
280 1.32 thorpej bus_space_handle_t ioh;
281 1.27 thorpej int i, rval;
282 1.100 thorpej static uint8_t pcb[EG_PCBLEN];
283 1.27 thorpej
284 1.27 thorpej rval = 0;
285 1.1 deraadt
286 1.75 ad /*
287 1.75 ad * XXX This probe is slow. If there are no ISA expansion slots,
288 1.75 ad * then skip it.
289 1.75 ad */
290 1.75 ad if (isa_get_slotcount() == 0)
291 1.75 ad return (0);
292 1.75 ad
293 1.57 thorpej if (ia->ia_nio < 1)
294 1.57 thorpej return (0);
295 1.57 thorpej if (ia->ia_nirq < 1)
296 1.57 thorpej return (0);
297 1.57 thorpej
298 1.57 thorpej if (ISA_DIRECT_CONFIG(ia))
299 1.57 thorpej return (0);
300 1.38 thorpej
301 1.38 thorpej /* Disallow wildcarded i/o address. */
302 1.63 drochner if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
303 1.38 thorpej return (0);
304 1.27 thorpej
305 1.57 thorpej /* Disallow wildcarded IRQ. */
306 1.63 drochner if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ)
307 1.57 thorpej return (0);
308 1.57 thorpej
309 1.57 thorpej if ((ia->ia_io[0].ir_addr & ~0x07f0) != 0) {
310 1.57 thorpej DPRINTF(("Weird iobase %x\n", ia->ia_io[0].ir_addr));
311 1.57 thorpej return 0;
312 1.57 thorpej }
313 1.57 thorpej
314 1.27 thorpej /* Map i/o space. */
315 1.57 thorpej if (bus_space_map(iot, ia->ia_io[0].ir_addr, 0x08, 0, &ioh)) {
316 1.29 christos DPRINTF(("egprobe: can't map i/o space in probe\n"));
317 1.27 thorpej return 0;
318 1.27 thorpej }
319 1.27 thorpej
320 1.1 deraadt /* hard reset card */
321 1.65 perry bus_space_write_1(iot, ioh, EG_CONTROL, EG_CTL_RESET);
322 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL, 0);
323 1.74 ad for (i = 0; i < 500; i++) {
324 1.1 deraadt delay(1000);
325 1.32 thorpej if ((bus_space_read_1(iot, ioh, EG_STATUS) &
326 1.65 perry EG_PCB_STAT) == EG_PCB_NULL)
327 1.1 deraadt break;
328 1.1 deraadt }
329 1.32 thorpej if ((bus_space_read_1(iot, ioh, EG_STATUS) & EG_PCB_STAT) != EG_PCB_NULL) {
330 1.29 christos DPRINTF(("egprobe: Reset failed\n"));
331 1.27 thorpej goto out;
332 1.1 deraadt }
333 1.40 drochner pcb[0] = EG_CMD_GETINFO; /* Get Adapter Info */
334 1.40 drochner pcb[1] = 0;
335 1.40 drochner if (egwritePCB(iot, ioh, pcb) != 0)
336 1.27 thorpej goto out;
337 1.27 thorpej
338 1.40 drochner if ((egreadPCB(iot, ioh, pcb) != 0) ||
339 1.40 drochner pcb[0] != EG_RSP_GETINFO || /* Get Adapter Info Response */
340 1.40 drochner pcb[1] != 0x0a) {
341 1.40 drochner egprintpcb(pcb);
342 1.27 thorpej goto out;
343 1.1 deraadt }
344 1.27 thorpej
345 1.57 thorpej ia->ia_nio = 1;
346 1.57 thorpej ia->ia_io[0].ir_size = 0x08;
347 1.57 thorpej
348 1.57 thorpej ia->ia_nirq = 1;
349 1.57 thorpej
350 1.57 thorpej ia->ia_niomem = 0;
351 1.57 thorpej ia->ia_ndrq = 0;
352 1.57 thorpej
353 1.27 thorpej rval = 1;
354 1.27 thorpej
355 1.27 thorpej out:
356 1.32 thorpej bus_space_unmap(iot, ioh, 0x08);
357 1.27 thorpej return rval;
358 1.1 deraadt }
359 1.1 deraadt
360 1.99 thorpej static void
361 1.80 cegger egattach(device_t parent, device_t self, void *aux)
362 1.1 deraadt {
363 1.85 chs struct eg_softc *sc = device_private(self);
364 1.2 mycroft struct isa_attach_args *ia = aux;
365 1.32 thorpej bus_space_tag_t iot = ia->ia_iot;
366 1.32 thorpej bus_space_handle_t ioh;
367 1.33 is struct ifnet *ifp = &sc->sc_ethercom.ec_if;
368 1.100 thorpej uint8_t myaddr[ETHER_ADDR_LEN];
369 1.27 thorpej
370 1.85 chs sc->sc_dev = self;
371 1.85 chs
372 1.30 christos printf("\n");
373 1.27 thorpej
374 1.27 thorpej /* Map i/o space. */
375 1.57 thorpej if (bus_space_map(iot, ia->ia_io[0].ir_addr, 0x08, 0, &ioh)) {
376 1.76 cegger aprint_error_dev(self, "can't map i/o space\n");
377 1.27 thorpej return;
378 1.27 thorpej }
379 1.27 thorpej
380 1.32 thorpej sc->sc_iot = iot;
381 1.27 thorpej sc->sc_ioh = ioh;
382 1.27 thorpej
383 1.40 drochner sc->eg_pcb[0] = EG_CMD_GETINFO; /* Get Adapter Info */
384 1.40 drochner sc->eg_pcb[1] = 0;
385 1.40 drochner if (egwritePCB(iot, ioh, sc->eg_pcb) != 0) {
386 1.76 cegger aprint_error_dev(self, "error requesting adapter info\n");
387 1.40 drochner return;
388 1.40 drochner }
389 1.40 drochner if (egreadPCB(iot, ioh, sc->eg_pcb) != 0) {
390 1.40 drochner egprintpcb(sc->eg_pcb);
391 1.76 cegger aprint_error_dev(self, "error reading adapter info\n");
392 1.40 drochner return;
393 1.40 drochner }
394 1.40 drochner
395 1.40 drochner if (sc->eg_pcb[0] != EG_RSP_GETINFO || /* Get Adapter Info Response */
396 1.40 drochner sc->eg_pcb[1] != 0x0a) {
397 1.40 drochner egprintpcb(sc->eg_pcb);
398 1.76 cegger aprint_error_dev(self, "bogus adapter info\n");
399 1.40 drochner return;
400 1.40 drochner }
401 1.40 drochner
402 1.40 drochner sc->eg_rom_major = sc->eg_pcb[3];
403 1.40 drochner sc->eg_rom_minor = sc->eg_pcb[2];
404 1.40 drochner sc->eg_ram = sc->eg_pcb[6] | (sc->eg_pcb[7] << 8);
405 1.40 drochner
406 1.2 mycroft egstop(sc);
407 1.1 deraadt
408 1.1 deraadt sc->eg_pcb[0] = EG_CMD_GETEADDR; /* Get Station address */
409 1.1 deraadt sc->eg_pcb[1] = 0;
410 1.40 drochner if (egwritePCB(iot, ioh, sc->eg_pcb) != 0) {
411 1.76 cegger aprint_error_dev(self, "can't send Get Station Address\n");
412 1.1 deraadt return;
413 1.65 perry }
414 1.40 drochner if (egreadPCB(iot, ioh, sc->eg_pcb) != 0) {
415 1.76 cegger aprint_error_dev(self, "can't read station address\n");
416 1.40 drochner egprintpcb(sc->eg_pcb);
417 1.1 deraadt return;
418 1.1 deraadt }
419 1.1 deraadt
420 1.1 deraadt /* check Get station address response */
421 1.65 perry if (sc->eg_pcb[0] != EG_RSP_GETEADDR || sc->eg_pcb[1] != 0x06) {
422 1.76 cegger aprint_error_dev(self, "card responded with garbage (1)\n");
423 1.40 drochner egprintpcb(sc->eg_pcb);
424 1.1 deraadt return;
425 1.1 deraadt }
426 1.54 thorpej memcpy(myaddr, &sc->eg_pcb[2], ETHER_ADDR_LEN);
427 1.1 deraadt
428 1.91 msaitoh aprint_normal_dev(self, "ROM v%d.%02d %dk address %s\n",
429 1.2 mycroft sc->eg_rom_major, sc->eg_rom_minor, sc->eg_ram,
430 1.33 is ether_sprintf(myaddr));
431 1.1 deraadt
432 1.1 deraadt sc->eg_pcb[0] = EG_CMD_SETEADDR; /* Set station address */
433 1.40 drochner if (egwritePCB(iot, ioh, sc->eg_pcb) != 0) {
434 1.91 msaitoh aprint_error_dev(self, "can't send Set Station Address\n");
435 1.1 deraadt return;
436 1.1 deraadt }
437 1.40 drochner if (egreadPCB(iot, ioh, sc->eg_pcb) != 0) {
438 1.91 msaitoh aprint_error_dev(self,
439 1.91 msaitoh "can't read Set Station Address status\n");
440 1.40 drochner egprintpcb(sc->eg_pcb);
441 1.1 deraadt return;
442 1.1 deraadt }
443 1.2 mycroft if (sc->eg_pcb[0] != EG_RSP_SETEADDR || sc->eg_pcb[1] != 0x02 ||
444 1.7 mycroft sc->eg_pcb[2] != 0 || sc->eg_pcb[3] != 0) {
445 1.76 cegger aprint_error_dev(self, "card responded with garbage (2)\n");
446 1.40 drochner egprintpcb(sc->eg_pcb);
447 1.1 deraadt return;
448 1.1 deraadt }
449 1.1 deraadt
450 1.2 mycroft /* Initialize ifnet structure. */
451 1.85 chs strlcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ);
452 1.25 thorpej ifp->if_softc = sc;
453 1.1 deraadt ifp->if_start = egstart;
454 1.1 deraadt ifp->if_ioctl = egioctl;
455 1.1 deraadt ifp->if_watchdog = egwatchdog;
456 1.96 msaitoh ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX;
457 1.52 thorpej IFQ_SET_READY(&ifp->if_snd);
458 1.52 thorpej
459 1.1 deraadt /* Now we can attach the interface. */
460 1.1 deraadt if_attach(ifp);
461 1.33 is ether_ifattach(ifp, myaddr);
462 1.65 perry
463 1.57 thorpej sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
464 1.57 thorpej IST_EDGE, IPL_NET, egintr, sc);
465 1.37 explorer
466 1.85 chs rnd_attach_source(&sc->rnd_source, device_xname(sc->sc_dev),
467 1.87 tls RND_TYPE_NET, RND_FLAG_DEFAULT);
468 1.1 deraadt }
469 1.1 deraadt
470 1.99 thorpej static void
471 1.78 dsl eginit(struct eg_softc *sc)
472 1.1 deraadt {
473 1.49 augustss struct ifnet *ifp = &sc->sc_ethercom.ec_if;
474 1.32 thorpej bus_space_tag_t iot = sc->sc_iot;
475 1.32 thorpej bus_space_handle_t ioh = sc->sc_ioh;
476 1.1 deraadt
477 1.1 deraadt /* soft reset the board */
478 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL, EG_CTL_FLSH);
479 1.1 deraadt delay(100);
480 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL, EG_CTL_ATTN);
481 1.1 deraadt delay(100);
482 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL, 0);
483 1.1 deraadt delay(200);
484 1.1 deraadt
485 1.1 deraadt sc->eg_pcb[0] = EG_CMD_CONFIG82586; /* Configure 82586 */
486 1.1 deraadt sc->eg_pcb[1] = 2;
487 1.1 deraadt sc->eg_pcb[2] = 3; /* receive broadcast & multicast */
488 1.1 deraadt sc->eg_pcb[3] = 0;
489 1.40 drochner if (egwritePCB(iot, ioh, sc->eg_pcb) != 0)
490 1.85 chs aprint_error_dev(sc->sc_dev, "can't send Configure 82586\n");
491 1.1 deraadt
492 1.40 drochner if (egreadPCB(iot, ioh, sc->eg_pcb) != 0) {
493 1.91 msaitoh aprint_error_dev(sc->sc_dev,
494 1.91 msaitoh "can't read Configure 82586 status\n");
495 1.40 drochner egprintpcb(sc->eg_pcb);
496 1.1 deraadt } else if (sc->eg_pcb[2] != 0 || sc->eg_pcb[3] != 0)
497 1.91 msaitoh aprint_error_dev(sc->sc_dev,"configure card command failed\n");
498 1.1 deraadt
499 1.27 thorpej if (sc->eg_inbuf == NULL) {
500 1.98 thorpej sc->eg_inbuf = kmem_alloc(EG_BUFLEN, KM_NOSLEEP);
501 1.27 thorpej if (sc->eg_inbuf == NULL) {
502 1.85 chs aprint_error_dev(sc->sc_dev, "can't allocate inbuf\n");
503 1.27 thorpej panic("eginit");
504 1.27 thorpej }
505 1.27 thorpej }
506 1.1 deraadt sc->eg_incount = 0;
507 1.1 deraadt
508 1.27 thorpej if (sc->eg_outbuf == NULL) {
509 1.98 thorpej sc->eg_outbuf = kmem_alloc(EG_BUFLEN, KM_NOSLEEP);
510 1.27 thorpej if (sc->eg_outbuf == NULL) {
511 1.91 msaitoh aprint_error_dev(sc->sc_dev,"can't allocate outbuf\n");
512 1.27 thorpej panic("eginit");
513 1.27 thorpej }
514 1.27 thorpej }
515 1.15 mycroft
516 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL, EG_CTL_CMDE);
517 1.16 mycroft
518 1.16 mycroft sc->eg_incount = 0;
519 1.16 mycroft egrecv(sc);
520 1.16 mycroft
521 1.16 mycroft /* Interface is now `running', with no output active. */
522 1.1 deraadt ifp->if_flags |= IFF_RUNNING;
523 1.1 deraadt ifp->if_flags &= ~IFF_OACTIVE;
524 1.1 deraadt
525 1.16 mycroft /* Attempt to start output, if any. */
526 1.1 deraadt egstart(ifp);
527 1.1 deraadt }
528 1.1 deraadt
529 1.99 thorpej static void
530 1.78 dsl egrecv(struct eg_softc *sc)
531 1.1 deraadt {
532 1.2 mycroft
533 1.1 deraadt while (sc->eg_incount < EG_INLEN) {
534 1.1 deraadt sc->eg_pcb[0] = EG_CMD_RECVPACKET;
535 1.1 deraadt sc->eg_pcb[1] = 0x08;
536 1.1 deraadt sc->eg_pcb[2] = 0; /* address not used.. we send zero */
537 1.1 deraadt sc->eg_pcb[3] = 0;
538 1.1 deraadt sc->eg_pcb[4] = 0;
539 1.1 deraadt sc->eg_pcb[5] = 0;
540 1.25 thorpej sc->eg_pcb[6] = EG_BUFLEN & 0xff; /* our buffer size */
541 1.25 thorpej sc->eg_pcb[7] = (EG_BUFLEN >> 8) & 0xff;
542 1.1 deraadt sc->eg_pcb[8] = 0; /* timeout, 0 == none */
543 1.1 deraadt sc->eg_pcb[9] = 0;
544 1.40 drochner if (egwritePCB(sc->sc_iot, sc->sc_ioh, sc->eg_pcb) != 0)
545 1.1 deraadt break;
546 1.16 mycroft sc->eg_incount++;
547 1.1 deraadt }
548 1.1 deraadt }
549 1.1 deraadt
550 1.99 thorpej static void
551 1.78 dsl egstart(struct ifnet *ifp)
552 1.1 deraadt {
553 1.49 augustss struct eg_softc *sc = ifp->if_softc;
554 1.32 thorpej bus_space_tag_t iot = sc->sc_iot;
555 1.32 thorpej bus_space_handle_t ioh = sc->sc_ioh;
556 1.1 deraadt struct mbuf *m0, *m;
557 1.72 christos char *buffer;
558 1.1 deraadt int len;
559 1.100 thorpej uint16_t *ptr;
560 1.1 deraadt
561 1.1 deraadt /* Don't transmit if interface is busy or not running */
562 1.15 mycroft if ((ifp->if_flags & (IFF_RUNNING|IFF_OACTIVE)) != IFF_RUNNING)
563 1.14 mycroft return;
564 1.1 deraadt
565 1.15 mycroft loop:
566 1.1 deraadt /* Dequeue the next datagram. */
567 1.52 thorpej IFQ_DEQUEUE(&ifp->if_snd, m0);
568 1.15 mycroft if (m0 == 0)
569 1.14 mycroft return;
570 1.65 perry
571 1.15 mycroft ifp->if_flags |= IFF_OACTIVE;
572 1.15 mycroft
573 1.15 mycroft /* We need to use m->m_pkthdr.len, so require the header */
574 1.27 thorpej if ((m0->m_flags & M_PKTHDR) == 0) {
575 1.85 chs aprint_error_dev(sc->sc_dev, "no header mbuf\n");
576 1.27 thorpej panic("egstart");
577 1.27 thorpej }
578 1.95 riastrad len = uimax(m0->m_pkthdr.len, ETHER_MIN_LEN - ETHER_CRC_LEN);
579 1.1 deraadt
580 1.94 msaitoh bpf_mtap(ifp, m0, BPF_D_OUT);
581 1.1 deraadt
582 1.1 deraadt sc->eg_pcb[0] = EG_CMD_SENDPACKET;
583 1.1 deraadt sc->eg_pcb[1] = 0x06;
584 1.1 deraadt sc->eg_pcb[2] = 0; /* address not used, we send zero */
585 1.1 deraadt sc->eg_pcb[3] = 0;
586 1.1 deraadt sc->eg_pcb[4] = 0;
587 1.1 deraadt sc->eg_pcb[5] = 0;
588 1.15 mycroft sc->eg_pcb[6] = len; /* length of packet */
589 1.15 mycroft sc->eg_pcb[7] = len >> 8;
590 1.40 drochner if (egwritePCB(iot, ioh, sc->eg_pcb) != 0) {
591 1.91 msaitoh aprint_error_dev(sc->sc_dev,
592 1.91 msaitoh "can't send Send Packet command\n");
593 1.97 thorpej if_statinc(ifp, if_oerrors);
594 1.15 mycroft ifp->if_flags &= ~IFF_OACTIVE;
595 1.27 thorpej m_freem(m0);
596 1.15 mycroft goto loop;
597 1.15 mycroft }
598 1.15 mycroft
599 1.15 mycroft buffer = sc->eg_outbuf;
600 1.15 mycroft for (m = m0; m != 0; m = m->m_next) {
601 1.72 christos memcpy(buffer, mtod(m, void *), m->m_len);
602 1.15 mycroft buffer += m->m_len;
603 1.1 deraadt }
604 1.61 bouyer if (len > m0->m_pkthdr.len)
605 1.61 bouyer memset(buffer, 0, len - m0->m_pkthdr.len);
606 1.15 mycroft
607 1.16 mycroft /* set direction bit: host -> adapter */
608 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL,
609 1.65 perry bus_space_read_1(iot, ioh, EG_CONTROL) & ~EG_CTL_DIR);
610 1.65 perry
611 1.100 thorpej for (ptr = (uint16_t *) sc->eg_outbuf; len > 0; len -= 2) {
612 1.32 thorpej bus_space_write_2(iot, ioh, EG_DATA, *ptr++);
613 1.32 thorpej while (!(bus_space_read_1(iot, ioh, EG_STATUS) & EG_STAT_HRDY))
614 1.15 mycroft ; /* XXX need timeout here */
615 1.15 mycroft }
616 1.65 perry
617 1.15 mycroft m_freem(m0);
618 1.1 deraadt }
619 1.1 deraadt
620 1.99 thorpej static int
621 1.78 dsl egintr(void *arg)
622 1.1 deraadt {
623 1.49 augustss struct eg_softc *sc = arg;
624 1.97 thorpej struct ifnet *ifp = &sc->sc_ethercom.ec_if;
625 1.32 thorpej bus_space_tag_t iot = sc->sc_iot;
626 1.32 thorpej bus_space_handle_t ioh = sc->sc_ioh;
627 1.27 thorpej int i, len, serviced;
628 1.100 thorpej uint16_t *ptr;
629 1.1 deraadt
630 1.27 thorpej serviced = 0;
631 1.27 thorpej
632 1.32 thorpej while (bus_space_read_1(iot, ioh, EG_STATUS) & EG_STAT_ACRF) {
633 1.40 drochner egreadPCB(iot, ioh, sc->eg_pcb);
634 1.2 mycroft switch (sc->eg_pcb[0]) {
635 1.1 deraadt case EG_RSP_RECVPACKET:
636 1.7 mycroft len = sc->eg_pcb[6] | (sc->eg_pcb[7] << 8);
637 1.65 perry
638 1.16 mycroft /* Set direction bit : Adapter -> host */
639 1.32 thorpej bus_space_write_1(iot, ioh, EG_CONTROL,
640 1.65 perry bus_space_read_1(iot, ioh, EG_CONTROL) | EG_CTL_DIR);
641 1.16 mycroft
642 1.100 thorpej for (ptr = (uint16_t *) sc->eg_inbuf;
643 1.27 thorpej len > 0; len -= 2) {
644 1.32 thorpej while (!(bus_space_read_1(iot, ioh, EG_STATUS) &
645 1.27 thorpej EG_STAT_HRDY))
646 1.1 deraadt ;
647 1.32 thorpej *ptr++ = bus_space_read_2(iot, ioh, EG_DATA);
648 1.1 deraadt }
649 1.16 mycroft
650 1.7 mycroft len = sc->eg_pcb[8] | (sc->eg_pcb[9] << 8);
651 1.1 deraadt egread(sc, sc->eg_inbuf, len);
652 1.16 mycroft
653 1.1 deraadt sc->eg_incount--;
654 1.16 mycroft egrecv(sc);
655 1.27 thorpej serviced = 1;
656 1.1 deraadt break;
657 1.1 deraadt
658 1.1 deraadt case EG_RSP_SENDPACKET:
659 1.1 deraadt if (sc->eg_pcb[6] || sc->eg_pcb[7]) {
660 1.29 christos DPRINTF(("%s: packet dropped\n",
661 1.85 chs device_xname(sc->sc_dev)));
662 1.97 thorpej if_statinc(ifp, if_oerrors);
663 1.2 mycroft } else
664 1.97 thorpej if_statinc(ifp, if_opackets);
665 1.97 thorpej if (sc->eg_pcb[8] & 0xf)
666 1.97 thorpej if_statadd(ifp, if_collisions,
667 1.97 thorpej sc->eg_pcb[8] & 0xf);
668 1.33 is sc->sc_ethercom.ec_if.if_flags &= ~IFF_OACTIVE;
669 1.33 is egstart(&sc->sc_ethercom.ec_if);
670 1.27 thorpej serviced = 1;
671 1.1 deraadt break;
672 1.1 deraadt
673 1.27 thorpej /* XXX byte-order and type-size bugs here... */
674 1.1 deraadt case EG_RSP_GETSTATS:
675 1.29 christos DPRINTF(("%s: Card Statistics\n",
676 1.85 chs device_xname(sc->sc_dev)));
677 1.54 thorpej memcpy(&i, &sc->eg_pcb[2], sizeof(i));
678 1.29 christos DPRINTF(("Receive Packets %d\n", i));
679 1.54 thorpej memcpy(&i, &sc->eg_pcb[6], sizeof(i));
680 1.29 christos DPRINTF(("Transmit Packets %d\n", i));
681 1.29 christos DPRINTF(("CRC errors %d\n",
682 1.27 thorpej *(short *) &sc->eg_pcb[10]));
683 1.29 christos DPRINTF(("alignment errors %d\n",
684 1.27 thorpej *(short *) &sc->eg_pcb[12]));
685 1.29 christos DPRINTF(("no resources errors %d\n",
686 1.27 thorpej *(short *) &sc->eg_pcb[14]));
687 1.29 christos DPRINTF(("overrun errors %d\n",
688 1.27 thorpej *(short *) &sc->eg_pcb[16]));
689 1.27 thorpej serviced = 1;
690 1.1 deraadt break;
691 1.65 perry
692 1.1 deraadt default:
693 1.30 christos printf("%s: egintr: Unknown response %x??\n",
694 1.85 chs device_xname(sc->sc_dev), sc->eg_pcb[0]);
695 1.40 drochner egprintpcb(sc->eg_pcb);
696 1.1 deraadt break;
697 1.1 deraadt }
698 1.37 explorer
699 1.37 explorer rnd_add_uint32(&sc->rnd_source, sc->eg_pcb[0]);
700 1.1 deraadt }
701 1.1 deraadt
702 1.27 thorpej return serviced;
703 1.1 deraadt }
704 1.1 deraadt
705 1.1 deraadt /*
706 1.1 deraadt * Pass a packet up to the higher levels.
707 1.1 deraadt */
708 1.99 thorpej static void
709 1.78 dsl egread(struct eg_softc *sc, void *buf, int len)
710 1.1 deraadt {
711 1.33 is struct ifnet *ifp = &sc->sc_ethercom.ec_if;
712 1.1 deraadt struct mbuf *m;
713 1.65 perry
714 1.1 deraadt if (len <= sizeof(struct ether_header) ||
715 1.1 deraadt len > ETHER_MAX_LEN) {
716 1.91 msaitoh aprint_error_dev(sc->sc_dev,
717 1.91 msaitoh "invalid packet size %d; dropping\n", len);
718 1.97 thorpej if_statinc(ifp, if_ierrors);
719 1.1 deraadt return;
720 1.1 deraadt }
721 1.1 deraadt
722 1.2 mycroft /* Pull packet off interface. */
723 1.18 mycroft m = egget(sc, buf, len);
724 1.1 deraadt if (m == 0) {
725 1.97 thorpej if_statinc(ifp, if_ierrors);
726 1.1 deraadt return;
727 1.1 deraadt }
728 1.1 deraadt
729 1.89 ozaki if_percpuq_enqueue(ifp->if_percpuq, m);
730 1.1 deraadt }
731 1.1 deraadt
732 1.1 deraadt /*
733 1.1 deraadt * convert buf into mbufs
734 1.1 deraadt */
735 1.99 thorpej static struct mbuf *
736 1.78 dsl egget(struct eg_softc *sc, void *buf, int totlen)
737 1.2 mycroft {
738 1.33 is struct ifnet *ifp = &sc->sc_ethercom.ec_if;
739 1.44 mycroft struct mbuf *m, *m0, *newm;
740 1.2 mycroft int len;
741 1.1 deraadt
742 1.44 mycroft MGETHDR(m0, M_DONTWAIT, MT_DATA);
743 1.44 mycroft if (m0 == 0)
744 1.44 mycroft return (0);
745 1.90 ozaki m_set_rcvif(m0, ifp);
746 1.44 mycroft m0->m_pkthdr.len = totlen;
747 1.2 mycroft len = MHLEN;
748 1.44 mycroft m = m0;
749 1.2 mycroft
750 1.2 mycroft while (totlen > 0) {
751 1.2 mycroft if (totlen >= MINCLSIZE) {
752 1.2 mycroft MCLGET(m, M_DONTWAIT);
753 1.44 mycroft if ((m->m_flags & M_EXT) == 0)
754 1.44 mycroft goto bad;
755 1.34 mycroft len = MCLBYTES;
756 1.2 mycroft }
757 1.44 mycroft
758 1.95 riastrad m->m_len = len = uimin(totlen, len);
759 1.72 christos memcpy(mtod(m, void *), buf, len);
760 1.72 christos buf = (char *)buf + len;
761 1.44 mycroft
762 1.2 mycroft totlen -= len;
763 1.44 mycroft if (totlen > 0) {
764 1.44 mycroft MGET(newm, M_DONTWAIT, MT_DATA);
765 1.44 mycroft if (newm == 0)
766 1.44 mycroft goto bad;
767 1.44 mycroft len = MLEN;
768 1.44 mycroft m = m->m_next = newm;
769 1.44 mycroft }
770 1.2 mycroft }
771 1.1 deraadt
772 1.44 mycroft return (m0);
773 1.44 mycroft
774 1.44 mycroft bad:
775 1.44 mycroft m_freem(m0);
776 1.44 mycroft return (0);
777 1.1 deraadt }
778 1.1 deraadt
779 1.99 thorpej static int
780 1.77 dyoung egioctl(struct ifnet *ifp, unsigned long cmd, void *data)
781 1.1 deraadt {
782 1.25 thorpej struct eg_softc *sc = ifp->if_softc;
783 1.18 mycroft struct ifaddr *ifa = (struct ifaddr *)data;
784 1.2 mycroft int s, error = 0;
785 1.2 mycroft
786 1.21 mycroft s = splnet();
787 1.2 mycroft
788 1.18 mycroft switch (cmd) {
789 1.1 deraadt
790 1.77 dyoung case SIOCINITIFADDR:
791 1.1 deraadt ifp->if_flags |= IFF_UP;
792 1.2 mycroft
793 1.77 dyoung eginit(sc);
794 1.1 deraadt switch (ifa->ifa_addr->sa_family) {
795 1.1 deraadt #ifdef INET
796 1.1 deraadt case AF_INET:
797 1.33 is arp_ifinit(ifp, ifa);
798 1.1 deraadt break;
799 1.1 deraadt #endif
800 1.1 deraadt default:
801 1.1 deraadt break;
802 1.1 deraadt }
803 1.1 deraadt break;
804 1.2 mycroft
805 1.1 deraadt case SIOCSIFFLAGS:
806 1.77 dyoung if ((error = ifioctl_common(ifp, cmd, data)) != 0)
807 1.77 dyoung break;
808 1.77 dyoung /* XXX re-use ether_ioctl() */
809 1.77 dyoung switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) {
810 1.77 dyoung case IFF_RUNNING:
811 1.2 mycroft /*
812 1.2 mycroft * If interface is marked down and it is running, then
813 1.2 mycroft * stop it.
814 1.2 mycroft */
815 1.2 mycroft egstop(sc);
816 1.1 deraadt ifp->if_flags &= ~IFF_RUNNING;
817 1.77 dyoung break;
818 1.77 dyoung case IFF_UP:
819 1.2 mycroft /*
820 1.2 mycroft * If interface is marked up and it is stopped, then
821 1.2 mycroft * start it.
822 1.2 mycroft */
823 1.1 deraadt eginit(sc);
824 1.77 dyoung break;
825 1.77 dyoung default:
826 1.3 deraadt sc->eg_pcb[0] = EG_CMD_GETSTATS;
827 1.3 deraadt sc->eg_pcb[1] = 0;
828 1.69 christos if (egwritePCB(sc->sc_iot, sc->sc_ioh, sc->eg_pcb) != 0) {
829 1.29 christos DPRINTF(("write error\n"));
830 1.69 christos }
831 1.1 deraadt /*
832 1.1 deraadt * XXX deal with flags changes:
833 1.1 deraadt * IFF_MULTICAST, IFF_PROMISC,
834 1.1 deraadt * IFF_LINK0, IFF_LINK1,
835 1.1 deraadt */
836 1.77 dyoung break;
837 1.1 deraadt }
838 1.1 deraadt break;
839 1.2 mycroft
840 1.1 deraadt default:
841 1.77 dyoung error = ether_ioctl(ifp, cmd, data);
842 1.18 mycroft break;
843 1.1 deraadt }
844 1.2 mycroft
845 1.2 mycroft splx(s);
846 1.2 mycroft return error;
847 1.1 deraadt }
848 1.1 deraadt
849 1.99 thorpej static void
850 1.78 dsl egreset(struct eg_softc *sc)
851 1.1 deraadt {
852 1.2 mycroft int s;
853 1.1 deraadt
854 1.85 chs DPRINTF(("%s: egreset()\n", device_xname(sc->sc_dev)));
855 1.21 mycroft s = splnet();
856 1.2 mycroft egstop(sc);
857 1.2 mycroft eginit(sc);
858 1.2 mycroft splx(s);
859 1.1 deraadt }
860 1.1 deraadt
861 1.99 thorpej static void
862 1.78 dsl egwatchdog(struct ifnet *ifp)
863 1.1 deraadt {
864 1.25 thorpej struct eg_softc *sc = ifp->if_softc;
865 1.1 deraadt
866 1.85 chs log(LOG_ERR, "%s: device timeout\n", device_xname(sc->sc_dev));
867 1.97 thorpej if_statinc(ifp, if_oerrors);
868 1.1 deraadt
869 1.1 deraadt egreset(sc);
870 1.1 deraadt }
871 1.1 deraadt
872 1.99 thorpej static void
873 1.78 dsl egstop(struct eg_softc *sc)
874 1.1 deraadt {
875 1.65 perry
876 1.32 thorpej bus_space_write_1(sc->sc_iot, sc->sc_ioh, EG_CONTROL, 0);
877 1.1 deraadt }
878