Lines Matching +defs:link +defs:flags

163 	int flags;
187 struct scsi_link *sc_link; /* our link to the adapter etc. */
269 struct scsi_link *link = sa->sa_sc_link;
272 SC_DEBUG(link, SDEV_DB2, ("stattach:\n"));
277 st->sc_link = link;
278 link->interpret_sense = st_interpret_sense;
279 link->device_softc = st;
283 &link->inqdata,
290 CLR(st->flags, ST_MODE_BLKSIZE | ST_MODE_DENSITY);
292 SET(st->flags, ST_MODE_BLKSIZE);
294 SET(st->flags, ST_MODE_DENSITY);
298 scsi_xsh_set(&st->sc_xsh, link, ststart);
315 CLR(link->flags, SDEV_MEDIA_LOADED);
328 SET(st->flags, ST_DYING);
337 stdetach(struct device *self, int flags)
362 stopen(dev_t dev, int flags, int fmt, struct proc *p)
364 struct scsi_link *link;
371 if (ISSET(st->flags, ST_DYING)) {
375 link = st->sc_link;
382 if (ISSET(flags, FWRITE) && ISSET(link->flags, SDEV_READONLY)) {
387 SC_DEBUG(link, SDEV_DB1, ("open: dev=0x%x (unit %d (of %d))\n", dev,
393 if (ISSET(link->flags, SDEV_OPEN)) {
394 SC_DEBUG(link, SDEV_DB4, ("already open\n"));
400 SET(link->flags, SDEV_OPEN);
406 error = scsi_test_unit_ready(link, TEST_READY_RETRIES,
413 if (!ISSET(link->flags, SDEV_MEDIA_LOADED))
417 CLR(link->flags, SDEV_OPEN);
421 error = st_mount_tape(st, flags);
423 CLR(link->flags, SDEV_OPEN);
432 if ((flags & O_ACCMODE) == FWRITE)
433 SET(st->flags, ST_WRITTEN);
436 SC_DEBUG(link, SDEV_DB2, ("open complete\n"));
447 stclose(dev_t dev, int flags, int mode, struct proc *p)
449 struct scsi_link *link;
456 if (ISSET(st->flags, ST_DYING)) {
460 link = st->sc_link;
464 SC_DEBUG(link, SDEV_DB1, ("closing\n"));
466 if (ISSET(st->flags, ST_WRITTEN) && !ISSET(st->flags, ST_FM_WRITTEN))
483 CLR(link->flags, SDEV_OPEN);
497 st_mount_tape(struct st_softc *st, int flags)
499 struct scsi_link *link = st->sc_link;
502 if (ISSET(st->flags, ST_MOUNTED))
505 SC_DEBUG(link, SDEV_DB1, ("mounting\n"));
521 scsi_test_unit_ready(link, TEST_READY_RETRIES, SCSI_SILENT);
534 if (!ISSET(link->flags, SDEV_ATAPI) &&
552 if (ISSET(st->flags, ST_MODE_DENSITY))
561 CLR(st->flags, ST_FIXEDBLOCKS);
562 if (ISSET(st->flags, ST_MODE_BLKSIZE)) {
565 SET(st->flags, ST_FIXEDBLOCKS);
574 scsi_prevent(link, PR_PREVENT,
576 SET(st->flags, ST_MOUNTED);
577 SET(link->flags, SDEV_MEDIA_LOADED); /* move earlier? */
589 * Reset various flags to indicate that all new
595 struct scsi_link *link = st->sc_link;
599 if (ISSET(link->flags, SDEV_MEDIA_LOADED))
606 if (!ISSET(st->flags, ST_MOUNTED))
608 SC_DEBUG(link, SDEV_DB1, ("unmounting\n"));
612 scsi_prevent(link, PR_ALLOW,
616 CLR(st->flags, ST_MOUNTED);
617 CLR(link->flags, SDEV_MEDIA_LOADED);
628 struct scsi_link *link = st->sc_link;
630 SC_DEBUG(link, SDEV_DB2, ("starting block mode decision\n"));
633 if (ISSET(link->flags, SDEV_ATAPI)) {
634 SET(st->flags, ST_FIXEDBLOCKS);
647 SET(st->flags, ST_FIXEDBLOCKS);
649 SC_DEBUG(link, SDEV_DB3,
662 CLR(st->flags, ST_FIXEDBLOCKS);
664 SC_DEBUG(link, SDEV_DB3, ("density specified variable\n"));
672 SET(st->flags, ST_FIXEDBLOCKS);
677 SC_DEBUG(link, SDEV_DB3, ("density specified fixed\n"));
687 SET(st->flags, ST_FIXEDBLOCKS);
689 CLR(st->flags, ST_FIXEDBLOCKS);
691 SC_DEBUG(link, SDEV_DB3,
699 CLR(st->flags, ST_FIXEDBLOCKS);
701 SC_DEBUG(link, SDEV_DB3,
721 CLR(st->flags, ST_2FM_AT_EOD);
724 SET(st->flags, ST_2FM_AT_EOD);
738 struct scsi_link *link;
747 if (ISSET(st->flags, ST_DYING)) {
751 link = st->sc_link;
753 SC_DEBUG(link, SDEV_DB2, ("ststrategy: %ld bytes @ blk %lld\n",
764 if (ISSET(st->flags, ST_FIXEDBLOCKS)) {
814 struct scsi_link *link = xs->sc_link;
815 struct st_softc *st = link->device_softc;
820 SC_DEBUG(link, SDEV_DB2, ("ststart\n"));
822 if (ISSET(st->flags, ST_DYING)) {
831 if (!ISSET(st->flags, ST_MOUNTED) ||
832 !ISSET(link->flags, SDEV_MEDIA_LOADED)) {
834 CLR(link->flags, SDEV_MEDIA_LOADED);
851 if (ISSET(st->flags, ST_FIXEDBLOCKS)) {
856 if (ISSET(st->flags, ST_AT_FILEMARK)) {
877 CLR(st->flags, ST_AT_FILEMARK);
890 if (ISSET(st->flags, ST_EOM_PENDING | ST_EIO_PENDING)) {
892 if (ISSET(st->flags, ST_EIO_PENDING)) {
896 CLR(st->flags, ST_EOM_PENDING | ST_EIO_PENDING);
912 CLR(st->flags, ST_FM_WRITTEN);
913 SET(st->flags, ST_WRITTEN);
914 SET(xs->flags, SCSI_DATA_OUT);
917 SET(xs->flags, SCSI_DATA_IN);
924 if (ISSET(st->flags, ST_FIXEDBLOCKS)) {
932 if (ISSET(st->flags, ST_FIXEDBLOCKS))
1023 struct scsi_link *link;
1029 link = sc->sc_link;
1031 if (link->bus->sb_adapter->dev_minphys != NULL)
1032 (*link->bus->sb_adapter->dev_minphys)(bp, link);
1060 int flags = 0;
1074 if (ISSET(st->flags, ST_DYING)) {
1101 if (ISSET(st->sc_link->flags, SDEV_READONLY))
1103 if (ISSET(st->flags, ST_MOUNTED))
1124 error = st_write_filemarks(st, number, flags);
1129 error = st_check_eod(st, 0, &nmarks, flags);
1132 SP_FILEMARKS, flags);
1137 error = st_check_eod(st, 1, &nmarks, flags);
1139 error = st_space(st, number, SP_BLKS, flags);
1142 error = st_rewind(st, 0, flags);
1150 error = st_load(st, LD_RETENSION, flags);
1152 error = st_load(st, LD_LOAD, flags);
1155 error = st_check_eod(st, 0, &nmarks, flags);
1157 error = st_space(st, 1, SP_EOM, flags);
1160 CLR(st->flags, ST_DONTBUFFER);
1163 SET(st->flags, ST_DONTBUFFER);
1166 error = st_erase(st, number, flags);
1170 CLR(st->flags, ST_FIXEDBLOCKS);
1178 SET(st->flags, ST_FIXEDBLOCKS);
1234 SET(st->flags, ST_FIXEDBLOCKS);
1236 CLR(st->flags, ST_FIXEDBLOCKS);
1246 SET(st->flags, ST_MODE_BLKSIZE);
1250 SET(st->flags, ST_MODE_DENSITY);
1263 st_read(struct st_softc *st, char *buf, int size, int flags)
1272 xs = scsi_xs_get(st->sc_link, flags | SCSI_DATA_IN);
1283 if (ISSET(st->flags, ST_FIXEDBLOCKS)) {
1300 st_read_block_limits(struct st_softc *st, int flags)
1304 struct scsi_link *link = st->sc_link;
1308 if (ISSET(link->flags, SDEV_MEDIA_LOADED))
1315 xs = scsi_xs_get(link, flags | SCSI_DATA_IN);
1335 SC_DEBUG(link, SDEV_DB3,
1356 st_mode_sense(struct st_softc *st, int flags)
1359 struct scsi_link *link = st->sc_link;
1376 error = scsi_do_mode_sense(link, 0, data, (void **)&page0, 1,
1377 flags | SCSI_SILENT, &big);
1380 scsi_parse_blkdesc(link, data, big, &density, &block_count,
1391 SET(link->flags, SDEV_READONLY);
1393 CLR(link->flags, SDEV_READONLY);
1398 SC_DEBUG(link, SDEV_DB3,
1401 ISSET(link->flags, SDEV_READONLY) ? "protected" : "enabled",
1404 SET(link->flags, SDEV_MEDIA_LOADED);
1417 st_mode_select(struct st_softc *st, int flags)
1421 struct scsi_link *link = st->sc_link;
1442 SC_DEBUG(link, SDEV_DB3,
1449 if (ISSET(link->flags, SDEV_ATAPI)) {
1457 if (ISSET(st->flags, ST_FIXEDBLOCKS))
1465 error = scsi_do_mode_sense(link, 0, inbuf, (void **)&page0, 1,
1466 flags | SCSI_SILENT, &big);
1494 if (!ISSET(st->flags, ST_DONTBUFFER))
1500 flags, ST_CTL_TIME);
1507 if (!ISSET(st->flags, ST_DONTBUFFER))
1514 flags, ST_CTL_TIME);
1527 st_erase(struct st_softc *st, int full, int flags)
1533 xs = scsi_xs_get(st->sc_link, flags);
1567 st_space(struct st_softc *st, int number, u_int what, int flags)
1575 if (ISSET(st->flags, ST_PER_ACTION)) {
1577 CLR(st->flags, ST_PER_ACTION);
1580 if (ISSET(st->flags, ST_AT_FILEMARK)) {
1587 flags);
1591 if (ISSET(st->flags, ST_BLANK_READ)) {
1592 CLR(st->flags, ST_BLANK_READ);
1595 CLR(st->flags, ST_EIO_PENDING | ST_EOM_PENDING);
1600 if (ISSET(st->flags, ST_EIO_PENDING)) {
1603 CLR(st->flags, ST_EIO_PENDING);
1607 CLR(st->flags, ST_EIO_PENDING);
1610 if (ISSET(st->flags, ST_AT_FILEMARK)) {
1611 CLR(st->flags, ST_AT_FILEMARK);
1614 if (ISSET(st->flags, ST_BLANK_READ) && (number < 0)) {
1616 CLR(st->flags, ST_BLANK_READ);
1621 if (ISSET(st->flags, ST_EOM_PENDING)) {
1623 CLR(st->flags, ST_EOM_PENDING);
1626 if (ISSET(st->flags, ST_EIO_PENDING)) {
1628 CLR(st->flags, ST_EIO_PENDING);
1631 if (ISSET(st->flags, ST_AT_FILEMARK))
1632 CLR(st->flags, ST_AT_FILEMARK);
1638 xs = scsi_xs_get(st->sc_link, flags);
1649 CLR(st->flags, ST_EOD_DETECTED);
1668 if (!ISSET(st->flags, ST_EOD_DETECTED))
1698 st_write_filemarks(struct st_softc *st, int number, int flags)
1707 xs = scsi_xs_get(st->sc_link, flags);
1718 if (ISSET(st->flags, ST_FM_WRITTEN)) /* already have one down */
1719 CLR(st->flags, ST_WRITTEN);
1721 SET(st->flags, ST_FM_WRITTEN);
1722 CLR(st->flags, ST_PER_ACTION);
1725 CLR(st->flags, ST_PER_ACTION | ST_WRITTEN);
1758 st_check_eod(struct st_softc *st, int position, int *nmarks, int flags)
1762 switch (st->flags & (ST_WRITTEN | ST_FM_WRITTEN | ST_2FM_AT_EOD)) {
1773 error = st_write_filemarks(st, *nmarks, flags);
1775 error = st_space(st, -*nmarks, SP_FILEMARKS, flags);
1783 st_load(struct st_softc *st, u_int type, int flags)
1794 error = st_check_eod(st, 0, &nmarks, flags);
1804 return st_rewind(st, 0, flags);
1810 xs = scsi_xs_get(st->sc_link, flags);
1830 st_rewind(struct st_softc *st, u_int immediate, int flags)
1836 error = st_check_eod(st, 0, &nmarks, flags);
1839 CLR(st->flags, ST_PER_ACTION);
1841 xs = scsi_xs_get(st->sc_link, flags);
1871 struct scsi_link *link = xs->sc_link;
1873 struct st_softc *st = link->device_softc;
1875 u_int8_t skey = sense->flags & SSD_KEY;
1879 if (!ISSET(link->flags, SDEV_OPEN) ||
1900 if (ISSET(xs->flags, SCSI_IGNORE_NOT_READY))
1904 SC_DEBUG(link, SDEV_DB1, ("not ready: busy (%#x)\n",
1918 SET(st->flags, ST_EOD_DETECTED);
1926 SET(st->flags, ST_BOD_DETECTED);
1949 if (ISSET(st->flags, ST_FIXEDBLOCKS))
1963 if (ISSET(st->flags, ST_FIXEDBLOCKS)) {
1968 if (ISSET(sense->flags, SSD_FILEMARK)) {
1975 if (!ISSET(st->flags, ST_FIXEDBLOCKS))
1977 SET(st->flags, ST_AT_FILEMARK);
1980 if (ISSET(sense->flags, SSD_EOM)) {
1981 SET(st->flags, ST_EOM_PENDING);
1983 if (ISSET(st->flags, ST_FIXEDBLOCKS))
1987 if (ISSET(sense->flags, SSD_ILI)) {
1988 if (!ISSET(st->flags, ST_FIXEDBLOCKS)) {
1991 if (!ISSET(xs->flags, SCSI_SILENT))
2000 if (!ISSET(xs->flags, SCSI_SILENT))
2003 SET(st->flags, ST_EIO_PENDING);
2010 !ISSET(link->flags, SDEV_MEDIA_LOADED))
2014 if (ISSET(st->flags, ST_FIXEDBLOCKS) && xs->resid == xs->datalen) {
2015 if (ISSET(st->flags, ST_EIO_PENDING))
2017 if (ISSET(st->flags, ST_AT_FILEMARK))
2028 !ISSET(link->flags, SDEV_MEDIA_LOADED)) {
2031 } else if (!ISSET(st->flags, ST_2FM_AT_EOD | ST_BLANK_READ)) {
2032 SET(st->flags, ST_BLANK_READ);
2033 SET(st->flags, ST_EOM_PENDING);
2079 SET(st->flags, ST_FIXEDBLOCKS);
2083 CLR(st->flags, ST_FIXEDBLOCKS);