Home | History | Annotate | Download | only in podulebus

Lines Matching defs:nexus

108 void sfas_init_nexus(struct sfas_softc *, struct nexus *);
125 struct nexus *sfas_arbitate_target(struct sfas_softc *, int);
126 void sfas_setup_nexus(struct sfas_softc *, struct nexus *,
130 int sfas_midaction(struct sfas_softc *, sfas_regmap_p, struct nexus *);
131 int sfas_postaction(struct sfas_softc *, sfas_regmap_p, struct nexus *);
134 void dump_nexus(struct nexus *nexus);
168 * Initialize the nexus structs.
171 sfas_init_nexus(struct sfas_softc *dev, struct nexus *nexus)
173 memset(nexus, 0, sizeof(struct nexus));
175 nexus->state = SFAS_NS_IDLE;
176 nexus->period = 200;
177 nexus->offset = 0;
178 nexus->syncper = 5;
179 nexus->syncoff = 0;
180 nexus->config3 = dev->sc_config3 & ~SFAS_CFG3_FASTSCSI;
338 struct nexus *nexus;
347 nexus = dev->sc_cur_nexus;
348 while(nexus->flags & SFAS_NF_UNIT_BUSY) {
353 nexus->flags |= SFAS_NF_UNIT_BUSY;
359 nexus->flags &= ~SFAS_NF_UNIT_BUSY;
485 * Save active data pointers to the nexus block currently active.
490 struct nexus *nx;
507 * Restore data pointers from the currently active nexus block.
512 struct nexus *nx;
640 struct nexus *nexus;
648 nexus = &dev->sc_nexus[target];
659 *rp->sfas_syncper = nexus->syncper;
660 *rp->sfas_syncoff = nexus->syncoff;
661 *rp->sfas_config3 = nexus->config3;
669 *rp->sfas_fifo = nexus->ID;
670 if ((nexus->flags & (SFAS_NF_DO_SDTR | SFAS_NF_RESET))
674 for(i=0; i<nexus->clen; i++)
675 *rp->sfas_fifo = nexus->cbuf[i];
680 dev->sc_sel_nexus = nexus;
684 nexus->flags &= ~SFAS_NF_RETRY_SELECT;
686 nexus->flags |= SFAS_NF_RETRY_SELECT;
688 nexus->flags |= SFAS_NF_RETRY_SELECT;
695 * Grab the nexus if available else return 0.
697 struct nexus *
700 struct nexus *nexus;
704 * This is really simple. Raise interrupt level to splbio. Grab the nexus and
707 nexus = &dev->sc_nexus[target];
711 if (nexus->flags & SFAS_NF_UNIT_BUSY)
712 nexus = 0;
714 nexus->flags |= SFAS_NF_UNIT_BUSY;
717 return(nexus);
721 * Setup a nexus for use. Initializes command, buffer pointers and DMA chain.
724 sfas_setup_nexus(struct sfas_softc *dev, struct nexus *nexus, struct sfas_pending *pendp, unsigned char *cbuf, int clen, unsigned char *buf, int len, int mode)
744 nexus->xs = pendp->xs;
746 /* Setup the nexus struct. */
747 nexus->ID = ((mode & SFAS_SELECT_R) ? 0xC0 : 0x80) | lun;
748 nexus->clen = clen;
749 memcpy(nexus->cbuf, cbuf, nexus->clen);
750 nexus->cbuf[1] |= lun << 5; /* Fix the lun bits */
751 nexus->cur_link = 0;
752 nexus->dma_len = 0;
753 nexus->dma_buf = 0;
754 nexus->dma_blk_len = 0;
755 nexus->dma_blk_ptr = 0;
756 nexus->len = len;
757 nexus->buf = buf;
758 nexus->lun_unit = (lun << 4) | target;
759 nexus->state = SFAS_NS_SELECTED;
762 nexus->flags &= SFAS_NF_UNIT_BUSY
766 nexus->flags |= SFAS_NF_IMMEDIATE;
768 nexus->flags |= SFAS_NF_RESET;
777 ((nexus->flags & SFAS_NF_SYNC_TESTED) && (nexus->offset != 0))) {
783 nexus->flags |= SFAS_NF_DO_SDTR;
784 nexus->period = 200;
785 nexus->offset = 0;
786 } else if (sync && !(nexus->flags & SFAS_NF_SYNC_TESTED)) {
794 nexus->flags |= SFAS_NF_DO_SDTR;
795 nexus->period = ((dev->sc_clock_freq>25) ? 100 : 200);
796 nexus->offset = 8;
799 if ((nexus->period == 100) &&
801 nexus->period = 200;
809 nexus->dma[0].ptr = buf;
810 nexus->dma[0].len = len;
811 nexus->dma[0].flg = SFAS_CHAIN_PRG;
812 nexus->max_link = 1;
814 nexus->max_link = dev->sc_build_dma_chain(dev, nexus->dma,
827 struct nexus *nexus;
829 /* Get the nexus struct. */
830 nexus = sfas_arbitate_target(dev, pendp->xs->xs_periph->periph_target);
831 if (nexus == NULL)
834 /* Setup the nexus struct. */
835 sfas_setup_nexus(dev, nexus, pendp, cbuf, clen, buf, len, mode);
878 * We don't know if we have an active nexus here!
883 struct nexus *nexus;
944 nexus = dev->sc_cur_nexus;
946 *rp->sfas_syncper = nexus->syncper;
947 *rp->sfas_syncoff = nexus->syncoff;
948 *rp->sfas_config3 = nexus->config3;
958 nexus->state = SFAS_NS_RESELECTED;
978 * processing. We know that we have an active nexus here.
981 sfas_midaction(struct sfas_softc *dev, sfas_regmap_p rp, struct nexus *nexus)
994 /* Let the nexus state reflect what we have to do. */
995 switch(nexus->state) {
998 nexus->flags &= ~SFAS_NF_SELECT_ME;
1004 nexus->xs->resid = dev->sc_len;
1006 nexus->status = -2;
1007 nexus->flags &= ~SFAS_NF_UNIT_BUSY;
1008 nexus->state = SFAS_NS_FINISHED;
1013 nexus->xs->resid = dev->sc_len;
1015 nexus->flags &= ~SFAS_NF_UNIT_BUSY;
1016 nexus->state = SFAS_NS_FINISHED;
1025 nexus->state = SFAS_NS_DISCONNECTED;
1033 * nexus struct.
1036 sfas_init_nexus(dev, nexus);
1046 nexus->lun_unit, nexus->state,
1048 nexus->flags, nexus->cbuf[0]);
1050 nexus->xs->resid = dev->sc_len;
1052 nexus->flags &= ~SFAS_NF_UNIT_BUSY;
1053 nexus->state = SFAS_NS_FINISHED;
1054 nexus->status = -3;
1070 /* Select the first pre-initialized nexus we find. */
1076 /* We are done with this nexus! */
1077 if (nexus->state == SFAS_NS_FINISHED)
1078 sfas_scsidone(dev, nexus->xs, nexus->status);
1083 switch(nexus->state) {
1085 dev->sc_cur_nexus = nexus;
1088 nexus->flags &= ~SFAS_NF_SELECT_ME;
1094 *rp->sfas_syncper = nexus->syncper;
1095 *rp->sfas_syncoff = nexus->syncoff;
1096 *rp->sfas_config3 = nexus->config3;
1100 nexus->status = 0xFF;
1120 if (nexus->state == SFAS_NS_DATA_IN) {
1173 nexus->status = status;
1175 nexus->status = -1;
1183 nexus->flags |= SFAS_NF_HAS_MSG;
1195 * phase passes). We know that we have an active nexus here.
1198 sfas_postaction(struct sfas_softc *dev, sfas_regmap_p rp, struct nexus *nexus)
1211 nexus->state = SFAS_NS_DATA_OUT;
1213 nexus->state = SFAS_NS_DATA_IN;
1227 dev->sc_ixfer(dev, nexus->xs->xs_control & XS_CTL_POLL);
1246 if (nexus->state == SFAS_NS_DATA_OUT)
1255 ((nexus->state == SFAS_NS_DATA_OUT) ?
1275 nexus->state = SFAS_NS_SVC;
1280 for(i=0; i<nexus->clen; i++)
1281 *rp->sfas_fifo = nexus->cbuf[i];
1290 nexus->state = SFAS_NS_STATUS;
1299 nexus->state = SFAS_NS_MSG_OUT;
1303 if (nexus->flags & SFAS_NF_DO_SDTR) {
1306 sfas_build_sdtrm(dev, nexus->period, nexus->offset);
1307 nexus->flags |= SFAS_NF_SDTR_SENT;
1308 nexus->flags &= ~SFAS_NF_DO_SDTR;
1309 } else if (nexus->flags & SFAS_NF_RESET) {
1314 nexus->state = SFAS_NS_RESET;
1315 nexus->flags &= ~SFAS_NF_RESET;
1333 nexus->state = SFAS_NS_MSG_IN;
1335 while(!(nexus->flags & SFAS_NF_HAS_MSG)) {
1348 nexus->flags |= SFAS_NF_HAS_MSG;
1353 nexus->flags |= SFAS_NF_HAS_MSG;
1367 if (nexus->flags & SFAS_NF_HAS_MSG) {
1372 nexus->state = SFAS_NS_DONE;
1375 nexus->state = SFAS_NS_DISCONNECTING;
1389 if (nexus->flags & SFAS_NF_SDTR_SENT) {
1390 nexus->flags &= ~SFAS_NF_SDTR_SENT;
1392 nexus->config3 &= ~SFAS_CFG3_FASTSCSI;
1393 nexus->syncper = 5;
1394 nexus->syncoff = 0;
1396 *rp->sfas_syncper = nexus->syncper;
1397 *rp->sfas_syncoff = nexus->syncoff;
1398 *rp->sfas_config3 = nexus->config3;
1433 nexus->syncper = period/
1435 nexus->syncoff = offset;
1438 nexus->config3 |= SFAS_CFG3_FASTSCSI;
1440 nexus->config3 &=~SFAS_CFG3_FASTSCSI;
1442 nexus->flags |= SFAS_NF_SYNC_TESTED;
1444 *rp->sfas_syncper = nexus->syncper;
1445 *rp->sfas_syncoff = nexus->syncoff;
1446 *rp->sfas_config3 = nexus->config3;
1453 if (!(nexus->flags& SFAS_NF_SDTR_SENT))
1460 nexus->lun_unit & 7]) {
1465 nexus->offset = offset;
1466 nexus->period = period;
1467 nexus->flags |= SFAS_NF_DO_SDTR;
1471 nexus->flags &= ~SFAS_NF_SDTR_SENT;
1497 nexus->flags &= ~SFAS_NF_HAS_MSG;
1505 sfas_scsidone(dev, nexus->xs, -4);
1523 struct nexus *nexus;
1529 nexus = dev->sc_cur_nexus;
1530 if (nexus == NULL)
1531 nexus = dev->sc_sel_nexus;
1533 if (nexus)
1534 if (!sfas_midaction(dev, rp, nexus))
1535 sfas_postaction(dev, rp, nexus);
1547 struct nexus *nexus;
1549 nexus = &dev->sc_nexus[pendp->xs->xs_periph->periph_target];
1556 while(nexus->state != SFAS_NS_FINISHED) {
1561 nexus->flags &= ~SFAS_NF_SYNC_TESTED;
1568 dump_nexus(struct nexus *nexus)
1572 printf("nexus=%08x\n", (u_int)nexus);
1573 printf("scsi_fer=%08x\n", (u_int)nexus->xs);
1574 printf("ID=%02x\n", nexus->ID);
1575 printf("clen=%02x\n", nexus->clen);
1578 printf(" %02x\n", nexus->cbuf[loop]);
1582 printf("dma_chain: %8p %04x %04x\n", (void *)nexus->dma[loop].ptr,
1583 nexus->dma[loop].len, nexus->dma[loop].flg);
1586 printf("max_link=%d\n", nexus->max_link);
1587 printf("cur_link=%d\n", nexus->cur_link);
1589 printf("buf=%08x\n", (u_int)nexus->buf);
1590 printf("len=%08x\n", nexus->len);
1591 printf("dma_buf=%08x\n", (u_int)nexus->dma_buf);
1592 printf("dma_len=%08x\n", nexus->dma_len);
1593 printf("dma_blk_ptr=%08x\n", (u_int)nexus->dma_blk_ptr);
1594 printf("dma_blk_len=%08x\n", nexus->dma_blk_len);
1595 printf("dma_blk_flag=%08x\n", nexus->dma_blk_flg);
1596 printf("state=%02x\n", nexus->state);
1597 printf("flags=%04x\n", nexus->flags);
1598 printf("period=%d\n", nexus->period);
1599 printf("offset=%d\n", nexus->offset);
1600 printf("syncper=%d\n", nexus->syncper);
1601 printf("syncoff=%d\n", nexus->syncoff);
1602 printf("config3=%02x\n", nexus->config3);
1603 printf("lun_unit=%d\n", nexus->lun_unit);
1604 printf("status=%02x\n", nexus->status);