summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2000-10-31 22:34:51 +0000
committermjacob <mjacob@FreeBSD.org>2000-10-31 22:34:51 +0000
commit708721e0c44fce2c7895648660d40f80c9ec9a82 (patch)
tree0364dc85f496f6f4feb98790ef55ee6e812d8476 /sys/cam
parent11bc42974263912f0a6fe465a2ce7721deaf4c6e (diff)
downloadFreeBSD-src-708721e0c44fce2c7895648660d40f80c9ec9a82.zip
FreeBSD-src-708721e0c44fce2c7895648660d40f80c9ec9a82.tar.gz
scsi_sa.h
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/scsi/scsi_sa.c33
-rw-r--r--sys/cam/scsi/scsi_sa.h14
2 files changed, 36 insertions, 11 deletions
diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c
index 4251f30..d14bbc4 100644
--- a/sys/cam/scsi/scsi_sa.c
+++ b/sys/cam/scsi/scsi_sa.c
@@ -344,6 +344,7 @@ static void sadone(struct cam_periph *periph,
union ccb *start_ccb);
static int saerror(union ccb *ccb, u_int32_t cam_flags,
u_int32_t sense_flags);
+static int samarkswanted(struct cam_periph *);
static int sacheckeod(struct cam_periph *periph);
static int sagetparams(struct cam_periph *periph,
sa_params params_to_get,
@@ -930,7 +931,12 @@ saioctl(dev_t dev, u_long cmd, caddr_t arg, int flag, struct proc *p)
count = mt->mt_count;
switch (mt->mt_op) {
case MTWEOF: /* write an end-of-file marker */
- /* XXXX: NEED TO CLEAR SA_TAPE_WRITTEN */
+ /*
+ * We don't need to clear the SA_FLAG_TAPE_WRITTEN
+ * flag because by keeping track of filemarks
+ * we have last written we know ehether or not
+ * we need to write more when we close the device.
+ */
error = sawritefilemarks(periph, count, FALSE);
break;
case MTWSS: /* write a setmark */
@@ -2167,24 +2173,39 @@ exit:
return (error);
}
+/*
+ * How many filemarks do we need to write if we were to terminate the
+ * tape session right now? Note that this can be a negative number
+ */
+
static int
-sacheckeod(struct cam_periph *periph)
+samarkswanted(struct cam_periph *periph)
{
- int error;
int markswanted;
struct sa_softc *softc;
softc = (struct sa_softc *)periph->softc;
markswanted = 0;
-
if ((softc->flags & SA_FLAG_TAPE_WRITTEN) != 0) {
markswanted++;
if (softc->quirks & SA_QUIRK_2FM)
markswanted++;
}
+ markswanted -= softc->filemarks;
+ return (markswanted);
+}
+
+static int
+sacheckeod(struct cam_periph *periph)
+{
+ int error;
+ int markswanted;
+ struct sa_softc *softc;
+
+ softc = (struct sa_softc *)periph->softc;
+ markswanted = samarkswanted(periph);
- if (softc->filemarks < markswanted) {
- markswanted -= softc->filemarks;
+ if (markswanted > 0) {
error = sawritefilemarks(periph, markswanted, FALSE);
} else {
error = 0;
diff --git a/sys/cam/scsi/scsi_sa.h b/sys/cam/scsi/scsi_sa.h
index be52eca..578b9d7 100644
--- a/sys/cam/scsi/scsi_sa.h
+++ b/sys/cam/scsi/scsi_sa.h
@@ -170,7 +170,7 @@ struct scsi_erase
struct scsi_dev_conf_page {
u_int8_t pagecode; /* 0x10 */
u_int8_t pagelength; /* 0x0e */
- u_int8_t byte2;
+ u_int8_t byte2; /* CAP, CAF, Active Format */
u_int8_t active_partition;
u_int8_t wb_full_ratio;
u_int8_t rb_empty_ratio;
@@ -189,23 +189,27 @@ struct scsi_dev_conf_page {
u_int8_t sel_comp_alg;
#define SA_COMP_NONE 0x00
#define SA_COMP_DEFAULT 0x01
- u_int8_t reserved;
+ /* the following is 'reserved' in SCSI-2 but is defined in SSC-r22 */
+ u_int8_t extra_wp;
+#define SA_ASOC_WP 0x04 /* Associated Write Protect */
+#define SA_PERS_WP 0x02 /* Persistent Write Protect */
+#define SA_PERM_WP 0x01 /* Permanent Write Protect */
};
/* from SCSI-3: SSC-Rev10 (6/97) */
struct scsi_data_compression_page {
u_int8_t page_code; /* 0x0f */
- u_int8_t page_length;
+ u_int8_t page_length; /* 0x0e */
+ u_int8_t dce_and_dcc;
#define SA_DCP_DCE 0x80 /* Data compression enable */
#define SA_DCP_DCC 0x40 /* Data compression capable */
- u_int8_t dce_and_dcc;
+ u_int8_t dde_and_red;
#define SA_DCP_DDE 0x80 /* Data decompression enable */
#define SA_DCP_RED_MASK 0x60 /* Report Exception on Decomp. */
#define SA_DCP_RED_SHAMT 5
#define SA_DCP_RED_0 0x00
#define SA_DCP_RED_1 0x20
#define SA_DCP_RED_2 0x40
- u_int8_t dde_and_red;
u_int8_t comp_algorithm[4];
u_int8_t decomp_algorithm[4];
u_int8_t reserved[4];
OpenPOWER on IntegriCloud