sci.c revision 1.15 1 /* $NetBSD: sci.c,v 1.15 1996/01/07 22:01:56 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1994 Michael L. Hitch
5 * Copyright (c) 1990 The Regents of the University of California.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to Berkeley by
9 * Van Jacobson of Lawrence Berkeley Laboratory.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 *
39 * @(#)scsi.c 7.5 (Berkeley) 5/4/91
40 */
41
42 /*
43 * AMIGA NCR 5380 scsi adaptor driver
44 */
45
46 #include <sys/param.h>
47 #include <sys/systm.h>
48 #include <sys/device.h>
49 #include <sys/disklabel.h>
50 #include <sys/dkstat.h>
51 #include <sys/buf.h>
52 #include <scsi/scsi_all.h>
53 #include <scsi/scsiconf.h>
54 #include <vm/vm.h>
55 #include <vm/vm_kern.h>
56 #include <vm/vm_page.h>
57 #include <machine/pmap.h>
58 #include <machine/cpu.h>
59 #include <amiga/amiga/device.h>
60 #include <amiga/amiga/custom.h>
61 #include <amiga/amiga/isr.h>
62 #include <amiga/dev/scireg.h>
63 #include <amiga/dev/scivar.h>
64
65 /*
66 * SCSI delays
67 * In u-seconds, primarily for state changes on the SPC.
68 */
69 #define SCI_CMD_WAIT 50000 /* wait per step of 'immediate' cmds */
70 #define SCI_DATA_WAIT 50000 /* wait per data in/out step */
71 #define SCI_INIT_WAIT 50000 /* wait per step (both) during init */
72
73 #define b_cylin b_resid
74
75 int sciicmd __P((struct sci_softc *, int, void *, int, void *, int,u_char));
76 int scigo __P((struct sci_softc *, struct scsi_xfer *));
77 int scigetsense __P((struct sci_softc *, struct scsi_xfer *));
78 int sciselectbus __P((struct sci_softc *, u_char, u_char));
79 void sciabort __P((struct sci_softc *, char *));
80 void scierror __P((struct sci_softc *, u_char));
81 void scireset __P((struct sci_softc *));
82 void scisetdelay __P((int));
83 void sci_scsidone __P((struct sci_softc *, int));
84 void sci_donextcmd __P((struct sci_softc *));
85
86 int sci_cmd_wait = SCI_CMD_WAIT;
87 int sci_data_wait = SCI_DATA_WAIT;
88 int sci_init_wait = SCI_INIT_WAIT;
89
90 int sci_no_dma = 0;
91
92 #ifdef DEBUG
93 #define QPRINTF(a) if (sci_debug > 1) printf a
94 int sci_debug = 0;
95 #else
96 #define QPRINTF
97 #endif
98
99 /*
100 * default minphys routine for sci based controllers
101 */
102 void
103 sci_minphys(bp)
104 struct buf *bp;
105 {
106
107 /*
108 * No max transfer at this level.
109 */
110 minphys(bp);
111 }
112
113 /*
114 * used by specific sci controller
115 *
116 * it appears that the higher level code does nothing with LUN's
117 * so I will too. I could plug it in, however so could they
118 * in scsi_scsi_cmd().
119 */
120 int
121 sci_scsicmd(xs)
122 struct scsi_xfer *xs;
123 {
124 struct sci_pending *pendp;
125 struct sci_softc *dev;
126 struct scsi_link *slp;
127 int flags, s;
128
129 slp = xs->sc_link;
130 dev = slp->adapter_softc;
131 flags = xs->flags;
132
133 if (flags & SCSI_DATA_UIO)
134 panic("sci: scsi data uio requested");
135
136 if (dev->sc_xs && flags & SCSI_POLL)
137 panic("sci_scsicmd: busy");
138
139 s = splbio();
140 pendp = &dev->sc_xsstore[slp->target][slp->lun];
141 if (pendp->xs) {
142 splx(s);
143 return(TRY_AGAIN_LATER);
144 }
145
146 if (dev->sc_xs) {
147 pendp->xs = xs;
148 TAILQ_INSERT_TAIL(&dev->sc_xslist, pendp, link);
149 splx(s);
150 return(SUCCESSFULLY_QUEUED);
151 }
152 pendp->xs = NULL;
153 dev->sc_xs = xs;
154 splx(s);
155
156 /*
157 * nothing is pending do it now.
158 */
159 sci_donextcmd(dev);
160
161 if (flags & SCSI_POLL)
162 return(COMPLETE);
163 return(SUCCESSFULLY_QUEUED);
164 }
165
166 /*
167 * entered with dev->sc_xs pointing to the next xfer to perform
168 */
169 void
170 sci_donextcmd(dev)
171 struct sci_softc *dev;
172 {
173 struct scsi_xfer *xs;
174 struct scsi_link *slp;
175 int flags, phase, stat;
176
177 xs = dev->sc_xs;
178 slp = xs->sc_link;
179 flags = xs->flags;
180
181 if (flags & SCSI_DATA_IN)
182 phase = DATA_IN_PHASE;
183 else if (flags & SCSI_DATA_OUT)
184 phase = DATA_OUT_PHASE;
185 else
186 phase = STATUS_PHASE;
187
188 if (flags & SCSI_RESET)
189 scireset(dev);
190
191 dev->sc_stat[0] = -1;
192 xs->cmd->bytes[0] |= slp->lun << 5;
193 if (phase == STATUS_PHASE || flags & SCSI_POLL)
194 stat = sciicmd(dev, slp->target, xs->cmd, xs->cmdlen,
195 xs->data, xs->datalen, phase);
196 else if (scigo(dev, xs) == 0)
197 return;
198 else
199 stat = dev->sc_stat[0];
200
201 sci_scsidone(dev, stat);
202 }
203
204 void
205 sci_scsidone(dev, stat)
206 struct sci_softc *dev;
207 int stat;
208 {
209 struct sci_pending *pendp;
210 struct scsi_xfer *xs;
211 int s, donext;
212
213 xs = dev->sc_xs;
214 #ifdef DIAGNOSTIC
215 if (xs == NULL)
216 panic("sci_scsidone");
217 #endif
218 /*
219 * XXX Support old-style instrumentation for now.
220 * IS THIS REALLY THE RIGHT PLACE FOR THIS? --thorpej
221 */
222 if (xs->sc_link->device_softc &&
223 ((struct device *)(xs->sc_link->device_softc))->dv_unit < dk_ndrive)
224 ++dk_xfer[((struct device *)(xs->sc_link->device_softc))->dv_unit];
225 /*
226 * is this right?
227 */
228 xs->status = stat;
229
230 if (stat == 0)
231 xs->resid = 0;
232 else {
233 switch(stat) {
234 case SCSI_CHECK:
235 if (stat = scigetsense(dev, xs))
236 goto bad_sense;
237 xs->error = XS_SENSE;
238 break;
239 case SCSI_BUSY:
240 xs->error = XS_BUSY;
241 break;
242 bad_sense:
243 default:
244 xs->error = XS_DRIVER_STUFFUP;
245 QPRINTF(("sci_scsicmd() bad %x\n", stat));
246 break;
247 }
248 }
249 xs->flags |= ITSDONE;
250
251 /*
252 * grab next command before scsi_done()
253 * this way no single device can hog scsi resources.
254 */
255 s = splbio();
256 pendp = dev->sc_xslist.tqh_first;
257 if (pendp == NULL) {
258 donext = 0;
259 dev->sc_xs = NULL;
260 } else {
261 donext = 1;
262 TAILQ_REMOVE(&dev->sc_xslist, pendp, link);
263 dev->sc_xs = pendp->xs;
264 pendp->xs = NULL;
265 }
266 splx(s);
267 scsi_done(xs);
268
269 if (donext)
270 sci_donextcmd(dev);
271 }
272
273 int
274 scigetsense(dev, xs)
275 struct sci_softc *dev;
276 struct scsi_xfer *xs;
277 {
278 struct scsi_sense rqs;
279 struct scsi_link *slp;
280 int stat;
281
282 slp = xs->sc_link;
283
284 rqs.opcode = REQUEST_SENSE;
285 rqs.byte2 = slp->lun << 5;
286 #ifdef not_yet
287 rqs.length = xs->req_sense_length ? xs->req_sense_length :
288 sizeof(xs->sense);
289 #else
290 rqs.length = sizeof(xs->sense);
291 #endif
292
293 rqs.unused[0] = rqs.unused[1] = rqs.control = 0;
294
295 return(sciicmd(dev, slp->target, &rqs, sizeof(rqs), &xs->sense,
296 rqs.length, DATA_IN_PHASE));
297 }
298
299 void
300 sciabort(dev, where)
301 struct sci_softc *dev;
302 char *where;
303 {
304 printf ("%s: abort %s: csr = 0x%02x, bus = 0x%02x\n",
305 dev->sc_dev.dv_xname, where, *dev->sci_csr, *dev->sci_bus_csr);
306
307 if (dev->sc_flags & SCI_SELECTED) {
308
309 /* lets just hope it worked.. */
310 dev->sc_flags &= ~SCI_SELECTED;
311 /* XXX */
312 scireset (dev);
313 }
314 }
315
316 /*
317 * XXX Set/reset long delays.
318 *
319 * if delay == 0, reset default delays
320 * if delay < 0, set both delays to default long initialization values
321 * if delay > 0, set both delays to this value
322 *
323 * Used when a devices is expected to respond slowly (e.g. during
324 * initialization).
325 */
326 void
327 scisetdelay(del)
328 int del;
329 {
330 static int saved_cmd_wait, saved_data_wait;
331
332 if (del) {
333 saved_cmd_wait = sci_cmd_wait;
334 saved_data_wait = sci_data_wait;
335 if (del > 0)
336 sci_cmd_wait = sci_data_wait = del;
337 else
338 sci_cmd_wait = sci_data_wait = sci_init_wait;
339 } else {
340 sci_cmd_wait = saved_cmd_wait;
341 sci_data_wait = saved_data_wait;
342 }
343 }
344
345 void
346 scireset(dev)
347 struct sci_softc *dev;
348 {
349 u_int i, s;
350 u_char my_id, csr;
351
352 dev->sc_flags &= ~SCI_SELECTED;
353 if (dev->sc_flags & SCI_ALIVE)
354 sciabort(dev, "reset");
355
356 printf("%s: ", dev->sc_dev.dv_xname);
357
358 s = splbio();
359 /* preserve our ID for now */
360 my_id = 7;
361
362 /*
363 * Reset the chip
364 */
365 *dev->sci_icmd = SCI_ICMD_TEST;
366 *dev->sci_icmd = SCI_ICMD_TEST | SCI_ICMD_RST;
367 delay (25);
368 *dev->sci_icmd = 0;
369
370 /*
371 * Set up various chip parameters
372 */
373 *dev->sci_icmd = 0;
374 *dev->sci_tcmd = 0;
375 *dev->sci_sel_enb = 0;
376
377 /* anything else was zeroed by reset */
378
379 splx (s);
380
381 printf("sci id %d\n", my_id);
382 dev->sc_flags |= SCI_ALIVE;
383 }
384
385 void
386 scierror(dev, csr)
387 struct sci_softc *dev;
388 u_char csr;
389 {
390 struct scsi_xfer *xs;
391
392 xs = dev->sc_xs;
393
394 #ifdef DIAGNOSTIC
395 if (xs == NULL)
396 panic("scierror");
397 #endif
398 if (xs->flags & SCSI_SILENT)
399 return;
400
401 printf("%s: ", dev->sc_dev.dv_xname);
402 printf("csr == 0x%02i\n", csr); /* XXX */
403 }
404
405 /*
406 * select the bus, return when selected or error.
407 */
408 int
409 sciselectbus(dev, target, our_addr)
410 struct sci_softc *dev;
411 u_char target, our_addr;
412 {
413 register int timeo = 2500;
414
415 QPRINTF (("sciselectbus %d\n", target));
416
417 /* if we're already selected, return */
418 if (dev->sc_flags & SCI_SELECTED) /* XXXX */
419 return 1;
420
421 if ((*dev->sci_bus_csr & (SCI_BUS_BSY|SCI_BUS_SEL)) &&
422 (*dev->sci_bus_csr & (SCI_BUS_BSY|SCI_BUS_SEL)) &&
423 (*dev->sci_bus_csr & (SCI_BUS_BSY|SCI_BUS_SEL)))
424 return 1;
425
426 *dev->sci_tcmd = 0;
427 *dev->sci_odata = 0x80 + (1 << target);
428 *dev->sci_icmd = SCI_ICMD_DATA|SCI_ICMD_SEL;
429 while ((*dev->sci_bus_csr & SCI_BUS_BSY) == 0) {
430 if (--timeo > 0) {
431 delay(100);
432 } else {
433 break;
434 }
435 }
436 if (timeo) {
437 *dev->sci_icmd = 0;
438 dev->sc_flags |= SCI_SELECTED;
439 return (0);
440 }
441 *dev->sci_icmd = 0;
442 return (1);
443 }
444
445 int
446 sci_ixfer_out(dev, len, buf, phase)
447 register struct sci_softc *dev;
448 int len;
449 register u_char *buf;
450 int phase;
451 {
452 register int wait = sci_data_wait;
453 u_char csr;
454
455 QPRINTF(("sci_ixfer_out {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
456 len, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
457 buf[6], buf[7], buf[8], buf[9]));
458
459 *dev->sci_tcmd = phase;
460 *dev->sci_icmd = SCI_ICMD_DATA;
461 for (;len > 0; len--) {
462 csr = *dev->sci_bus_csr;
463 while (!(csr & SCI_BUS_REQ)) {
464 if ((csr & SCI_BUS_BSY) == 0 || --wait < 0) {
465 #ifdef DEBUG
466 if (sci_debug)
467 printf("sci_ixfer_out fail: l%d i%x w%d\n",
468 len, csr, wait);
469 #endif
470 return (len);
471 }
472 delay(1);
473 csr = *dev->sci_bus_csr;
474 }
475
476 if (!(*dev->sci_csr & SCI_CSR_PHASE_MATCH))
477 break;
478 *dev->sci_odata = *buf;
479 *dev->sci_icmd = SCI_ICMD_DATA|SCI_ICMD_ACK;
480 buf++;
481 while (*dev->sci_bus_csr & SCI_BUS_REQ);
482 *dev->sci_icmd = SCI_ICMD_DATA;
483 }
484
485 QPRINTF(("sci_ixfer_out done\n"));
486 return (0);
487 }
488
489 void
490 sci_ixfer_in(dev, len, buf, phase)
491 struct sci_softc *dev;
492 int len;
493 register u_char *buf;
494 int phase;
495 {
496 int wait = sci_data_wait;
497 u_char *obp = buf;
498 u_char csr;
499 volatile register u_char *sci_bus_csr = dev->sci_bus_csr;
500 volatile register u_char *sci_data = dev->sci_data;
501 volatile register u_char *sci_icmd = dev->sci_icmd;
502
503 csr = *sci_bus_csr;
504
505 QPRINTF(("sci_ixfer_in %d, csr=%02x\n", len, csr));
506
507 *dev->sci_tcmd = phase;
508 *sci_icmd = 0;
509 for (;len > 0; len--) {
510 csr = *sci_bus_csr;
511 while (!(csr & SCI_BUS_REQ)) {
512 if (!(csr & SCI_BUS_BSY) || --wait < 0) {
513 #ifdef DEBUG
514 if (sci_debug)
515 printf("sci_ixfer_in fail: l%d i%x w%d\n",
516 len, csr, wait);
517 #endif
518 return;
519 }
520
521 delay(1);
522 csr = *sci_bus_csr;
523 }
524
525 if (!(*dev->sci_csr & SCI_CSR_PHASE_MATCH))
526 break;
527 *buf = *sci_data;
528 *sci_icmd = SCI_ICMD_ACK;
529 buf++;
530 while (*sci_bus_csr & SCI_BUS_REQ);
531 *sci_icmd = 0;
532 }
533
534 QPRINTF(("sci_ixfer_in {%d} %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
535 len, obp[0], obp[1], obp[2], obp[3], obp[4], obp[5],
536 obp[6], obp[7], obp[8], obp[9]));
537 }
538
539 /*
540 * SCSI 'immediate' command: issue a command to some SCSI device
541 * and get back an 'immediate' response (i.e., do programmed xfer
542 * to get the response data). 'cbuf' is a buffer containing a scsi
543 * command of length clen bytes. 'buf' is a buffer of length 'len'
544 * bytes for data. The transfer direction is determined by the device
545 * (i.e., by the scsi bus data xfer phase). If 'len' is zero, the
546 * command must supply no data. 'xferphase' is the bus phase the
547 * caller expects to happen after the command is issued. It should
548 * be one of DATA_IN_PHASE, DATA_OUT_PHASE or STATUS_PHASE.
549 */
550 int
551 sciicmd(dev, target, cbuf, clen, buf, len, xferphase)
552 struct sci_softc *dev;
553 void *cbuf, *buf;
554 int clen, len;
555 u_char xferphase;
556 {
557 u_char phase, csr, asr;
558 register int wait;
559
560 /* select the SCSI bus (it's an error if bus isn't free) */
561 if (sciselectbus (dev, target, dev->sc_scsi_addr))
562 return -1;
563 /*
564 * Wait for a phase change (or error) then let the device
565 * sequence us through the various SCSI phases.
566 */
567 dev->sc_stat[0] = 0xff;
568 dev->sc_msg[0] = 0xff;
569 phase = CMD_PHASE;
570 while (1) {
571 wait = sci_cmd_wait;
572
573 while ((*dev->sci_bus_csr & (SCI_BUS_REQ|SCI_BUS_BSY)) == SCI_BUS_BSY);
574
575 QPRINTF((">CSR:%02x<", *dev->sci_bus_csr));
576 if ((*dev->sci_bus_csr & SCI_BUS_REQ) == 0) {
577 return -1;
578 }
579 phase = SCI_PHASE(*dev->sci_bus_csr);
580
581 switch (phase) {
582 case CMD_PHASE:
583 if (sci_ixfer_out (dev, clen, cbuf, phase))
584 goto abort;
585 phase = xferphase;
586 break;
587
588 case DATA_IN_PHASE:
589 if (len <= 0)
590 goto abort;
591 wait = sci_data_wait;
592 sci_ixfer_in (dev, len, buf, phase);
593 phase = STATUS_PHASE;
594 break;
595
596 case DATA_OUT_PHASE:
597 if (len <= 0)
598 goto abort;
599 wait = sci_data_wait;
600 if (sci_ixfer_out (dev, len, buf, phase))
601 goto abort;
602 phase = STATUS_PHASE;
603 break;
604
605 case MESG_IN_PHASE:
606 dev->sc_msg[0] = 0xff;
607 sci_ixfer_in (dev, 1, dev->sc_msg,phase);
608 dev->sc_flags &= ~SCI_SELECTED;
609 while (*dev->sci_bus_csr & SCI_BUS_BSY);
610 goto out;
611 break;
612
613 case MESG_OUT_PHASE:
614 phase = STATUS_PHASE;
615 break;
616
617 case STATUS_PHASE:
618 sci_ixfer_in (dev, 1, dev->sc_stat, phase);
619 phase = MESG_IN_PHASE;
620 break;
621
622 case BUS_FREE_PHASE:
623 goto out;
624
625 default:
626 printf("sci: unexpected phase %d in icmd from %d\n",
627 phase, target);
628 goto abort;
629 }
630 #if 0
631 if (wait <= 0)
632 goto abort;
633 #endif
634 }
635
636 abort:
637 sciabort(dev, "icmd");
638 out:
639 QPRINTF(("=STS:%02x=", dev->sc_stat[0]));
640 return (dev->sc_stat[0]);
641 }
642
643 int
644 scigo(dev, xs)
645 struct sci_softc *dev;
646 struct scsi_xfer *xs;
647 {
648 int i, count, target;
649 u_char phase, csr, asr, cmd, *addr;
650 int wait;
651
652 target = xs->sc_link->target;
653 count = xs->datalen;
654 addr = xs->data;
655
656 if (sci_no_dma) {
657 sciicmd (dev, target, (u_char *) xs->cmd, xs->cmdlen,
658 addr, count,
659 xs->flags & SCSI_DATA_IN ? DATA_IN_PHASE : DATA_OUT_PHASE);
660
661 return (1);
662 }
663
664 /* select the SCSI bus (it's an error if bus isn't free) */
665 if (sciselectbus (dev, target, dev->sc_scsi_addr))
666 return -1;
667 /*
668 * Wait for a phase change (or error) then let the device
669 * sequence us through the various SCSI phases.
670 */
671 dev->sc_stat[0] = 0xff;
672 dev->sc_msg[0] = 0xff;
673 phase = CMD_PHASE;
674 while (1) {
675 while ((*dev->sci_bus_csr & (SCI_BUS_REQ|SCI_BUS_BSY)) ==
676 SCI_BUS_BSY);
677
678 QPRINTF((">CSR:%02x<", *dev->sci_bus_csr));
679 if ((*dev->sci_bus_csr & SCI_BUS_REQ) == 0) {
680 goto abort;
681 }
682 phase = SCI_PHASE(*dev->sci_bus_csr);
683
684 switch (phase) {
685 case CMD_PHASE:
686 if (sci_ixfer_out (dev, xs->cmdlen, xs->cmd, phase))
687 goto abort;
688 phase = xs->flags & SCSI_DATA_IN ? DATA_IN_PHASE : DATA_OUT_PHASE;
689 break;
690
691 case DATA_IN_PHASE:
692 if (count <= 0)
693 goto abort;
694 /* XXX use psuedo DMA if available */
695 if (count >= 128 && dev->dma_xfer_in)
696 (*dev->dma_xfer_in)(dev, count, addr, phase);
697 else
698 sci_ixfer_in (dev, count, addr, phase);
699 phase = STATUS_PHASE;
700 break;
701
702 case DATA_OUT_PHASE:
703 if (count <= 0)
704 goto abort;
705 /* XXX use psuedo DMA if available */
706 if (count >= 128 && dev->dma_xfer_out)
707 (*dev->dma_xfer_out)(dev, count, addr, phase);
708 else
709 if (sci_ixfer_out (dev, count, addr, phase))
710 goto abort;
711 phase = STATUS_PHASE;
712 break;
713
714 case MESG_IN_PHASE:
715 dev->sc_msg[0] = 0xff;
716 sci_ixfer_in (dev, 1, dev->sc_msg,phase);
717 dev->sc_flags &= ~SCI_SELECTED;
718 while (*dev->sci_bus_csr & SCI_BUS_BSY);
719 goto out;
720 break;
721
722 case MESG_OUT_PHASE:
723 phase = STATUS_PHASE;
724 break;
725
726 case STATUS_PHASE:
727 sci_ixfer_in (dev, 1, dev->sc_stat, phase);
728 phase = MESG_IN_PHASE;
729 break;
730
731 case BUS_FREE_PHASE:
732 goto out;
733
734 default:
735 printf("sci: unexpected phase %d in icmd from %d\n",
736 phase, target);
737 goto abort;
738 }
739 }
740
741 abort:
742 sciabort(dev, "go");
743 out:
744 QPRINTF(("=STS:%02x=", dev->sc_stat[0]));
745 return (1);
746 }
747