if_de.c revision 1.10 1 /* $NetBSD: if_de.c,v 1.10 2001/05/06 15:27:48 ragge Exp $ */
2
3 /*
4 * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
5 * Copyright (c) 2000 Ludd, University of Lule}, Sweden.
6 * All rights reserved.
7 *
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)if_de.c 7.12 (Berkeley) 12/16/90
38 */
39
40 /*
41 * DEC DEUNA interface
42 *
43 * Lou Salkind
44 * New York University
45 *
46 * Rewritten by Ragge 30 April 2000 to match new world.
47 *
48 * TODO:
49 * timeout routine (get statistics)
50 */
51
52 #include "opt_inet.h"
53 #include "bpfilter.h"
54
55 #include <sys/param.h>
56 #include <sys/systm.h>
57 #include <sys/mbuf.h>
58 #include <sys/buf.h>
59 #include <sys/protosw.h>
60 #include <sys/socket.h>
61 #include <sys/ioctl.h>
62 #include <sys/errno.h>
63 #include <sys/syslog.h>
64 #include <sys/device.h>
65
66 #include <net/if.h>
67 #include <net/if_ether.h>
68 #include <net/if_dl.h>
69
70 #ifdef INET
71 #include <netinet/in.h>
72 #include <netinet/if_inarp.h>
73 #endif
74
75 #if NBPFILTER > 0
76 #include <net/bpf.h>
77 #include <net/bpfdesc.h>
78 #endif
79
80 #include <machine/bus.h>
81
82 #include <dev/qbus/ubavar.h>
83 #include <dev/qbus/if_dereg.h>
84 #include <dev/qbus/if_uba.h>
85
86 #include "ioconf.h"
87
88 /*
89 * Be careful with transmit/receive buffers, each entry steals 4 map
90 * registers, and there is only 496 on one unibus...
91 */
92 #define NRCV 7 /* number of receive buffers (must be > 1) */
93 #define NXMT 3 /* number of transmit buffers */
94
95 /*
96 * Structure containing the elements that must be in DMA-safe memory.
97 */
98 struct de_cdata {
99 /* the following structures are always mapped in */
100 struct de_pcbb dc_pcbb; /* port control block */
101 struct de_ring dc_xrent[NXMT]; /* transmit ring entrys */
102 struct de_ring dc_rrent[NRCV]; /* receive ring entrys */
103 struct de_udbbuf dc_udbbuf; /* UNIBUS data buffer */
104 /* end mapped area */
105 };
106
107 /*
108 * Ethernet software status per interface.
109 *
110 * Each interface is referenced by a network interface structure,
111 * ds_if, which the routing code uses to locate the interface.
112 * This structure contains the output queue for the interface, its address, ...
113 * We also have, for each interface, a UBA interface structure, which
114 * contains information about the UNIBUS resources held by the interface:
115 * map registers, buffered data paths, etc. Information is cached in this
116 * structure for use by the if_uba.c routines in running the interface
117 * efficiently.
118 */
119 struct de_softc {
120 struct device sc_dev; /* Configuration common part */
121 struct evcnt sc_intrcnt; /* Interrupt counting */
122 struct ethercom sc_ec; /* Ethernet common part */
123 #define sc_if sc_ec.ec_if /* network-visible interface */
124 bus_space_tag_t sc_iot;
125 bus_addr_t sc_ioh;
126 bus_dma_tag_t sc_dmat;
127 int sc_flags;
128 #define DSF_MAPPED 1
129 struct ubinfo sc_ui;
130 struct de_cdata *sc_dedata; /* Control structure */
131 struct de_cdata *sc_pdedata; /* Bus-mapped control structure */
132 struct ifubinfo sc_ifuba; /* UNIBUS resources */
133 struct ifrw sc_ifr[NRCV]; /* UNIBUS receive buffer maps */
134 struct ifxmt sc_ifw[NXMT]; /* UNIBUS receive buffer maps */
135
136 int sc_xindex; /* UNA index into transmit chain */
137 int sc_rindex; /* UNA index into receive chain */
138 int sc_xfree; /* index for next transmit buffer */
139 int sc_nxmit; /* # of transmits in progress */
140 void *sc_sh; /* shutdownhook cookie */
141 };
142
143 static int dematch(struct device *, struct cfdata *, void *);
144 static void deattach(struct device *, struct device *, void *);
145 static void dewait(struct de_softc *, char *);
146 static int deinit(struct ifnet *);
147 static int deioctl(struct ifnet *, u_long, caddr_t);
148 static void dereset(struct device *);
149 static void destop(struct ifnet *, int);
150 static void destart(struct ifnet *);
151 static void derecv(struct de_softc *);
152 static void deintr(void *);
153 static void deshutdown(void *);
154
155 struct cfattach de_ca = {
156 sizeof(struct de_softc), dematch, deattach
157 };
158
159 #define DE_WCSR(csr, val) \
160 bus_space_write_2(sc->sc_iot, sc->sc_ioh, csr, val)
161 #define DE_WLOW(val) \
162 bus_space_write_1(sc->sc_iot, sc->sc_ioh, DE_PCSR0, val)
163 #define DE_WHIGH(val) \
164 bus_space_write_1(sc->sc_iot, sc->sc_ioh, DE_PCSR0 + 1, val)
165 #define DE_RCSR(csr) \
166 bus_space_read_2(sc->sc_iot, sc->sc_ioh, csr)
167
168 #define LOWORD(x) ((int)(x) & 0xffff)
169 #define HIWORD(x) (((int)(x) >> 16) & 0x3)
170 /*
171 * Interface exists: make available by filling in network interface
172 * record. System will initialize the interface when it is ready
173 * to accept packets. We get the ethernet address here.
174 */
175 void
176 deattach(struct device *parent, struct device *self, void *aux)
177 {
178 struct uba_attach_args *ua = aux;
179 struct de_softc *sc = (struct de_softc *)self;
180 struct ifnet *ifp = &sc->sc_if;
181 u_int8_t myaddr[ETHER_ADDR_LEN];
182 int csr1, error;
183 char *c;
184
185 sc->sc_iot = ua->ua_iot;
186 sc->sc_ioh = ua->ua_ioh;
187 sc->sc_dmat = ua->ua_dmat;
188
189 /*
190 * What kind of a board is this?
191 * The error bits 4-6 in pcsr1 are a device id as long as
192 * the high byte is zero.
193 */
194 csr1 = DE_RCSR(DE_PCSR1);
195 if (csr1 & 0xff60)
196 c = "broken";
197 else if (csr1 & 0x10)
198 c = "delua";
199 else
200 c = "deuna";
201
202 /*
203 * Reset the board and temporarily map
204 * the pcbb buffer onto the Unibus.
205 */
206 DE_WCSR(DE_PCSR0, 0); /* reset INTE */
207 DELAY(100);
208 DE_WCSR(DE_PCSR0, PCSR0_RSET);
209 dewait(sc, "reset");
210
211 sc->sc_ui.ui_size = sizeof(struct de_cdata);
212 if ((error = ubmemalloc((struct uba_softc *)parent, &sc->sc_ui, 0)))
213 return printf(": failed ubmemalloc(), error = %d\n", error);
214 sc->sc_dedata = (struct de_cdata *)sc->sc_ui.ui_vaddr;
215
216 /*
217 * Tell the DEUNA about our PCB
218 */
219 DE_WCSR(DE_PCSR2, LOWORD(sc->sc_ui.ui_baddr));
220 DE_WCSR(DE_PCSR3, HIWORD(sc->sc_ui.ui_baddr));
221 DE_WLOW(CMD_GETPCBB);
222 dewait(sc, "pcbb");
223
224 sc->sc_dedata->dc_pcbb.pcbb0 = FC_RDPHYAD;
225 DE_WLOW(CMD_GETCMD);
226 dewait(sc, "read addr ");
227
228 bcopy((caddr_t)&sc->sc_dedata->dc_pcbb.pcbb2, myaddr, sizeof (myaddr));
229 printf("\n%s: %s, hardware address %s\n", sc->sc_dev.dv_xname, c,
230 ether_sprintf(myaddr));
231
232 uba_intr_establish(ua->ua_icookie, ua->ua_cvec, deintr, sc,
233 &sc->sc_intrcnt);
234 uba_reset_establish(dereset, &sc->sc_dev);
235 evcnt_attach_dynamic(&sc->sc_intrcnt, EVCNT_TYPE_INTR, ua->ua_evcnt,
236 sc->sc_dev.dv_xname, "intr");
237
238 strcpy(ifp->if_xname, sc->sc_dev.dv_xname);
239 ifp->if_softc = sc;
240 ifp->if_flags = IFF_BROADCAST|IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI;
241 ifp->if_ioctl = deioctl;
242 ifp->if_start = destart;
243 ifp->if_init = deinit;
244 ifp->if_stop = destop;
245 IFQ_SET_READY(&ifp->if_snd);
246
247 if_attach(ifp);
248 ether_ifattach(ifp, myaddr);
249 ubmemfree((struct uba_softc *)parent, &sc->sc_ui);
250
251 sc->sc_sh = shutdownhook_establish(deshutdown, sc);
252 }
253
254 void
255 destop(struct ifnet *ifp, int a)
256 {
257 struct de_softc *sc = ifp->if_softc;
258
259 DE_WLOW(0);
260 DELAY(5000);
261 DE_WLOW(PCSR0_RSET);
262 }
263
264
265 /*
266 * Reset of interface after UNIBUS reset.
267 */
268 void
269 dereset(struct device *dev)
270 {
271 struct de_softc *sc = (void *)dev;
272
273 sc->sc_if.if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
274 sc->sc_flags &= ~DSF_MAPPED;
275 sc->sc_pdedata = NULL; /* All mappings lost */
276 DE_WCSR(DE_PCSR0, PCSR0_RSET);
277 dewait(sc, "reset");
278 deinit(&sc->sc_if);
279 }
280
281 /*
282 * Initialization of interface; clear recorded pending
283 * operations, and reinitialize UNIBUS usage.
284 */
285 int
286 deinit(struct ifnet *ifp)
287 {
288 struct de_softc *sc = ifp->if_softc;
289 struct de_cdata *dc, *pdc;
290 struct ifrw *ifrw;
291 struct ifxmt *ifxp;
292 struct de_ring *rp;
293 int s, error;
294
295 if (ifp->if_flags & IFF_RUNNING)
296 return 0;
297 if ((sc->sc_flags & DSF_MAPPED) == 0) {
298 if (if_ubaminit(&sc->sc_ifuba, (void *)sc->sc_dev.dv_parent,
299 MCLBYTES, sc->sc_ifr, NRCV, sc->sc_ifw, NXMT)) {
300 printf("%s: can't initialize\n", sc->sc_dev.dv_xname);
301 ifp->if_flags &= ~IFF_UP;
302 return 0;
303 }
304 sc->sc_ui.ui_size = sizeof(struct de_cdata);
305 if ((error = ubmemalloc((void *)sc->sc_dev.dv_parent,
306 &sc->sc_ui, 0))) {
307 printf(": unable to ubmemalloc(), error = %d\n", error);
308 return 0;
309 }
310 sc->sc_pdedata = (struct de_cdata *)sc->sc_ui.ui_baddr;
311 sc->sc_dedata = (struct de_cdata *)sc->sc_ui.ui_vaddr;
312 sc->sc_flags |= DSF_MAPPED;
313 }
314
315 /*
316 * Tell the DEUNA about our PCB
317 */
318 DE_WCSR(DE_PCSR2, LOWORD(sc->sc_pdedata));
319 DE_WCSR(DE_PCSR3, HIWORD(sc->sc_pdedata));
320 DE_WLOW(0); /* reset INTE */
321 DELAY(500);
322 DE_WLOW(CMD_GETPCBB);
323 dewait(sc, "pcbb");
324
325 dc = sc->sc_dedata;
326 pdc = sc->sc_pdedata;
327 /* set the transmit and receive ring header addresses */
328 dc->dc_pcbb.pcbb0 = FC_WTRING;
329 dc->dc_pcbb.pcbb2 = LOWORD(&pdc->dc_udbbuf);
330 dc->dc_pcbb.pcbb4 = HIWORD(&pdc->dc_udbbuf);
331
332 dc->dc_udbbuf.b_tdrbl = LOWORD(&pdc->dc_xrent[0]);
333 dc->dc_udbbuf.b_tdrbh = HIWORD(&pdc->dc_xrent[0]);
334 dc->dc_udbbuf.b_telen = sizeof (struct de_ring) / sizeof(u_int16_t);
335 dc->dc_udbbuf.b_trlen = NXMT;
336 dc->dc_udbbuf.b_rdrbl = LOWORD(&pdc->dc_rrent[0]);
337 dc->dc_udbbuf.b_rdrbh = HIWORD(&pdc->dc_rrent[0]);
338 dc->dc_udbbuf.b_relen = sizeof (struct de_ring) / sizeof(u_int16_t);
339 dc->dc_udbbuf.b_rrlen = NRCV;
340
341 DE_WLOW(CMD_GETCMD);
342 dewait(sc, "wtring");
343
344 sc->sc_dedata->dc_pcbb.pcbb0 = FC_WTMODE;
345 sc->sc_dedata->dc_pcbb.pcbb2 = MOD_TPAD|MOD_HDX|MOD_DRDC|MOD_ENAL;
346 DE_WLOW(CMD_GETCMD);
347 dewait(sc, "wtmode");
348
349 /* set up the receive and transmit ring entries */
350 ifxp = &sc->sc_ifw[0];
351 for (rp = &dc->dc_xrent[0]; rp < &dc->dc_xrent[NXMT]; rp++) {
352 rp->r_segbl = LOWORD(ifxp->ifw_info);
353 rp->r_segbh = HIWORD(ifxp->ifw_info);
354 rp->r_flags = 0;
355 ifxp++;
356 }
357 ifrw = &sc->sc_ifr[0];
358 for (rp = &dc->dc_rrent[0]; rp < &dc->dc_rrent[NRCV]; rp++) {
359 rp->r_slen = MCLBYTES - 2;
360 rp->r_segbl = LOWORD(ifrw->ifrw_info);
361 rp->r_segbh = HIWORD(ifrw->ifrw_info);
362 rp->r_flags = RFLG_OWN;
363 ifrw++;
364 }
365
366 /* start up the board (rah rah) */
367 s = splnet();
368 sc->sc_rindex = sc->sc_xindex = sc->sc_xfree = sc->sc_nxmit = 0;
369 sc->sc_if.if_flags |= IFF_RUNNING;
370 DE_WLOW(PCSR0_INTE); /* avoid interlock */
371 destart(&sc->sc_if); /* queue output packets */
372 DE_WLOW(CMD_START|PCSR0_INTE);
373 splx(s);
374 return 0;
375 }
376
377 /*
378 * Setup output on interface.
379 * Get another datagram to send off of the interface queue,
380 * and map it to the interface before starting the output.
381 * Must be called from ipl >= our interrupt level.
382 */
383 void
384 destart(struct ifnet *ifp)
385 {
386 struct de_softc *sc = ifp->if_softc;
387 struct de_cdata *dc;
388 struct de_ring *rp;
389 struct mbuf *m;
390 int nxmit, len;
391
392 /*
393 * the following test is necessary, since
394 * the code is not reentrant and we have
395 * multiple transmission buffers.
396 */
397 if (sc->sc_if.if_flags & IFF_OACTIVE)
398 return;
399 dc = sc->sc_dedata;
400 for (nxmit = sc->sc_nxmit; nxmit < NXMT; nxmit++) {
401 IFQ_DEQUEUE(&ifp->if_snd, m);
402 if (m == 0)
403 break;
404
405 rp = &dc->dc_xrent[sc->sc_xfree];
406 if (rp->r_flags & XFLG_OWN)
407 panic("deuna xmit in progress");
408 #if NBPFILTER > 0
409 if (ifp->if_bpf)
410 bpf_mtap(ifp->if_bpf, m);
411 #endif
412
413 len = if_ubaput(&sc->sc_ifuba, &sc->sc_ifw[sc->sc_xfree], m);
414 rp->r_slen = len;
415 rp->r_tdrerr = 0;
416 rp->r_flags = XFLG_STP|XFLG_ENP|XFLG_OWN;
417
418 sc->sc_xfree++;
419 if (sc->sc_xfree == NXMT)
420 sc->sc_xfree = 0;
421 }
422 if (sc->sc_nxmit != nxmit) {
423 sc->sc_nxmit = nxmit;
424 if (ifp->if_flags & IFF_RUNNING)
425 DE_WLOW(PCSR0_INTE|CMD_PDMD);
426 }
427 }
428
429 /*
430 * Command done interrupt.
431 */
432 void
433 deintr(void *arg)
434 {
435 struct ifxmt *ifxp;
436 struct de_cdata *dc;
437 struct de_softc *sc = arg;
438 struct de_ring *rp;
439 short csr0;
440
441 /* save flags right away - clear out interrupt bits */
442 csr0 = DE_RCSR(DE_PCSR0);
443 DE_WHIGH(csr0 >> 8);
444
445
446 sc->sc_if.if_flags |= IFF_OACTIVE; /* prevent entering destart */
447 /*
448 * if receive, put receive buffer on mbuf
449 * and hang the request again
450 */
451 derecv(sc);
452
453 /*
454 * Poll transmit ring and check status.
455 * Be careful about loopback requests.
456 * Then free buffer space and check for
457 * more transmit requests.
458 */
459 dc = sc->sc_dedata;
460 for ( ; sc->sc_nxmit > 0; sc->sc_nxmit--) {
461 rp = &dc->dc_xrent[sc->sc_xindex];
462 if (rp->r_flags & XFLG_OWN)
463 break;
464
465 sc->sc_if.if_opackets++;
466 ifxp = &sc->sc_ifw[sc->sc_xindex];
467 /* check for unusual conditions */
468 if (rp->r_flags & (XFLG_ERRS|XFLG_MTCH|XFLG_ONE|XFLG_MORE)) {
469 if (rp->r_flags & XFLG_ERRS) {
470 /* output error */
471 sc->sc_if.if_oerrors++;
472 } else if (rp->r_flags & XFLG_ONE) {
473 /* one collision */
474 sc->sc_if.if_collisions++;
475 } else if (rp->r_flags & XFLG_MORE) {
476 /* more than one collision */
477 sc->sc_if.if_collisions += 2; /* guess */
478 }
479 }
480 if_ubaend(&sc->sc_ifuba, ifxp);
481 /* check if next transmit buffer also finished */
482 sc->sc_xindex++;
483 if (sc->sc_xindex == NXMT)
484 sc->sc_xindex = 0;
485 }
486 sc->sc_if.if_flags &= ~IFF_OACTIVE;
487 destart(&sc->sc_if);
488
489 if (csr0 & PCSR0_RCBI) {
490 DE_WLOW(PCSR0_INTE|CMD_PDMD);
491 }
492 }
493
494 /*
495 * Ethernet interface receiver interface.
496 * If input error just drop packet.
497 * Otherwise purge input buffered data path and examine
498 * packet to determine type. If can't determine length
499 * from type, then have to drop packet. Othewise decapsulate
500 * packet based on type and pass to type specific higher-level
501 * input routine.
502 */
503 void
504 derecv(struct de_softc *sc)
505 {
506 struct ifnet *ifp = &sc->sc_if;
507 struct de_ring *rp;
508 struct de_cdata *dc;
509 struct mbuf *m;
510 int len;
511
512 dc = sc->sc_dedata;
513 rp = &dc->dc_rrent[sc->sc_rindex];
514 while ((rp->r_flags & RFLG_OWN) == 0) {
515 sc->sc_if.if_ipackets++;
516 len = (rp->r_lenerr&RERR_MLEN) - ETHER_CRC_LEN;
517 /* check for errors */
518 if ((rp->r_flags & (RFLG_ERRS|RFLG_FRAM|RFLG_OFLO|RFLG_CRC)) ||
519 (rp->r_lenerr & (RERR_BUFL|RERR_UBTO))) {
520 sc->sc_if.if_ierrors++;
521 goto next;
522 }
523 m = if_ubaget(&sc->sc_ifuba, &sc->sc_ifr[sc->sc_rindex],
524 ifp, len);
525 if (m == 0) {
526 sc->sc_if.if_ierrors++;
527 goto next;
528 }
529 #if NBPFILTER > 0
530 if (ifp->if_bpf)
531 bpf_mtap(ifp->if_bpf, m);
532 #endif
533
534 (*ifp->if_input)(ifp, m);
535
536 /* hang the receive buffer again */
537 next: rp->r_lenerr = 0;
538 rp->r_flags = RFLG_OWN;
539
540 /* check next receive buffer */
541 sc->sc_rindex++;
542 if (sc->sc_rindex == NRCV)
543 sc->sc_rindex = 0;
544 rp = &dc->dc_rrent[sc->sc_rindex];
545 }
546 }
547
548 /*
549 * Process an ioctl request.
550 */
551 int
552 deioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
553 {
554 int s, error = 0;
555
556 s = splnet();
557
558 error = ether_ioctl(ifp, cmd, data);
559 if (error == ENETRESET)
560 error = 0;
561
562 splx(s);
563 return (error);
564 }
565
566 /*
567 * Await completion of the named function
568 * and check for errors.
569 */
570 void
571 dewait(struct de_softc *sc, char *fn)
572 {
573 int csr0;
574
575 while ((DE_RCSR(DE_PCSR0) & PCSR0_INTR) == 0)
576 ;
577 csr0 = DE_RCSR(DE_PCSR0);
578 DE_WHIGH(csr0 >> 8);
579 if (csr0 & PCSR0_PCEI) {
580 char bits[64];
581 printf("%s: %s failed, csr0=%s ", sc->sc_dev.dv_xname, fn,
582 bitmask_snprintf(csr0, PCSR0_BITS, bits, sizeof(bits)));
583 printf("csr1=%s\n", bitmask_snprintf(DE_RCSR(DE_PCSR1),
584 PCSR1_BITS, bits, sizeof(bits)));
585 }
586 }
587
588 int
589 dematch(struct device *parent, struct cfdata *cf, void *aux)
590 {
591 struct uba_attach_args *ua = aux;
592 struct de_softc ssc;
593 struct de_softc *sc = &ssc;
594 int i;
595
596 sc->sc_iot = ua->ua_iot;
597 sc->sc_ioh = ua->ua_ioh;
598 /*
599 * Make sure self-test is finished before we screw with the board.
600 * Self-test on a DELUA can take 15 seconds (argh).
601 */
602 for (i = 0;
603 (i < 160) &&
604 (DE_RCSR(DE_PCSR0) & PCSR0_FATI) == 0 &&
605 (DE_RCSR(DE_PCSR1) & PCSR1_STMASK) == STAT_RESET;
606 ++i)
607 DELAY(50000);
608 if (((DE_RCSR(DE_PCSR0) & PCSR0_FATI) != 0) ||
609 (((DE_RCSR(DE_PCSR1) & PCSR1_STMASK) != STAT_READY) &&
610 ((DE_RCSR(DE_PCSR1) & PCSR1_STMASK) != STAT_RUN)))
611 return(0);
612
613 DE_WCSR(DE_PCSR0, 0);
614 DELAY(5000);
615 DE_WCSR(DE_PCSR0, PCSR0_RSET);
616 while ((DE_RCSR(DE_PCSR0) & PCSR0_INTR) == 0)
617 ;
618 /* make board interrupt by executing a GETPCBB command */
619 DE_WCSR(DE_PCSR0, PCSR0_INTE);
620 DE_WCSR(DE_PCSR2, 0);
621 DE_WCSR(DE_PCSR3, 0);
622 DE_WCSR(DE_PCSR0, PCSR0_INTE|CMD_GETPCBB);
623 DELAY(50000);
624
625 return 1;
626 }
627
628 void
629 deshutdown(void *arg)
630 {
631 struct de_softc *sc = arg;
632
633 DE_WCSR(DE_PCSR0, 0);
634 DELAY(1000);
635 DE_WCSR(DE_PCSR0, PCSR0_RSET);
636 dewait(sc, "shutdown");
637 }
638