xref: /csrg-svn/sys/dev/scsi/disktape.h (revision 63144)
154877Storek /*
2*63144Sbostic  * Copyright (c) 1992, 1993
3*63144Sbostic  *	The Regents of the University of California.  All rights reserved.
454877Storek  *
554877Storek  * This software was developed by the Computer Systems Engineering group
654877Storek  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
754877Storek  * contributed to Berkeley.
854877Storek  *
955559Storek  * All advertising materials mentioning features or use of this software
1055559Storek  * must display the following acknowledgement:
1155559Storek  *	This product includes software developed by the University of
1255559Storek  *	California, Lawrence Berkeley Laboratories.
1355559Storek  *
1454877Storek  * %sccs.include.redist.c%
1554877Storek  *
16*63144Sbostic  *	@(#)disktape.h	8.1 (Berkeley) 06/10/93
1754877Storek  *
1859534Storek  * from: $Header: disktape.h,v 1.4 93/04/30 00:02:16 torek Exp $ (LBL)
1954877Storek  */
2054877Storek 
2154877Storek /*
2254877Storek  * Commands common to disk and tape devices, but not other SCSI devices.
2354877Storek  */
2457750Storek #define	CMD_MODE_SELECT6	0x15	/* mode select (6 byte cdb) */
2557750Storek #define	CMD_MODE_SENSE6		0x1a	/* mode sense (6 byte cdb) */
2654877Storek 
2757750Storek #define	CMD_MODE_SELECT10	0x55	/* mode select (10 byte cdb) */
2857750Storek #define	CMD_MODE_SENSE10	0x5a	/* mode sense (10 byte cdb) */
2957750Storek 
3054877Storek /*
3157750Storek  * Structure of MODE SELECT commands (i.e., the cdb; 6 & 10 byte flavors).
3257750Storek  * The only difference is that the 10-byte version can give more parameter
3357750Storek  * bytes.
3454877Storek  */
3557750Storek struct scsi_cdb_modeselect6 {
3657750Storek 	u_char	cdb_cmd,	/* 0x15 */
3757750Storek 		cdb_lun_flags,	/* LUN + flags */
3857750Storek 		cdb_xxx[2],	/* reserved */
3957750Storek 		cdb_len,	/* parameter list length */
4057750Storek 		cdb_ctrl;	/* control byte */
4157750Storek };
4257750Storek struct scsi_cdb_modeselect10 {
4357750Storek 	u_char	cdb_cmd,	/* 0x55 */
4457750Storek 		cdb_lun_flags,	/* LUN + flags */
4557750Storek 		cdb_xxx[5],	/* reserved */
4657750Storek 		cdb_lenh,	/* parameter list length (MSB) */
4757750Storek 		cdb_lenl,	/* parameter list length (LSB) */
4857750Storek 		cdb_ctrl;	/* control byte */
4957750Storek };
5057750Storek /* flags in SCSI_MODESELECT commands */
5157750Storek #define	SCSI_MSEL_SCSI1_DATA	0x00	/* SCSI-1 data format */
5257750Storek #define	SCSI_MSEL_SCSI2_DATA	0x10	/* SCSI-2 data format */
5357750Storek #define	SCSI_MSEL_DONTSAVE	0x00	/* don't save pages */
5457750Storek #define	SCSI_MSEL_SAVEPAGES	0x01	/* save mode pages */
5557750Storek 
5657750Storek /*
5757750Storek  * Structure of MODE SENSE command (i.e., the cdb; 6 & 10 byte flavors).
5857750Storek  * Again, the 10-byte version merely allows more parameter bytes.
5959534Storek  * Note that these lengths include the MODE SENSE headers, while those
6059534Storek  * for individual mode pages do not.  (Consistency?  What's that?)
6157750Storek  */
6257750Storek struct scsi_cdb_modesense6 {
6357750Storek 	u_char	cdb_cmd,	/* 0x1a */
6457750Storek 		cdb_lun_flags,	/* logical unit number + flags */
6557750Storek 		cdb_pcc,	/* page control & code */
6657750Storek 		cdb_xxx,	/* reserved */
6754877Storek 		cdb_len,	/* allocation length */
6854877Storek 		cdb_ctrl;	/* control byte */
6954877Storek };
7057750Storek struct scsi_cdb_modesense10 {
7157750Storek 	u_char	cdb_cmd,	/* 0x5a */
7257750Storek 		cdb_lun_flags,	/* logical unit number + flags */
7357750Storek 		cdb_pcc,	/* page control & code */
7457750Storek 		cdb_xxx[4],	/* reserved */
7557750Storek 		cdb_lenh,	/* allocation length (MSB) */
7657750Storek 		cdb_lenl,	/* allocation length (MSB) */
7757750Storek 		cdb_ctrl;	/* control byte */
7857750Storek };
7957750Storek /* flags in SCSI_MODESENSE commands */
8057750Storek #define	SCSI_MSENSE_DBD		0x08	/* device returns db descriptors */
8154877Storek 
8257750Storek /* page controls */
8357750Storek #define	SCSI_MSENSE_PCTL_CUR	0x00	/* return current parameters */
8457750Storek #define	SCSI_MSENSE_PCTL_VAR	0x40	/* return variable parameters */
8557750Storek #define	SCSI_MSENSE_PCTL_DFLT	0x80	/* return default parameters */
8657750Storek #define	SCSI_MSENSE_PCTL_SAVED	0xc0	/* return saved parameters */
8757750Storek 
8854877Storek /*
8957750Storek  * Both MODE_SENSE and MODE_SELECT use a Mode Parameter Header,
9057750Storek  * followed by an array of Block Descriptors, followed by an array
9157750Storek  * of Pages.  We define structures for the Block Descriptor and Page
9259534Storek  * header first, then the two (6 and 10 byte) Mode Parameter headers
9359534Storek  * (not including the Block Descriptor(s) and any mode pages themselves).
9454877Storek  */
9557750Storek struct scsi_ms_bd {		/* mode sense/select block descriptor */
9657750Storek 	u_char	bd_dc,		/* density code (tapes only) */
9757750Storek 		bd_nbh,		/* number of blocks (MSB) */
9857750Storek 		bd_nbm,		/* number of blocks */
9957750Storek 		bd_nbl,		/* number of blocks (LSB) */
10057750Storek 		bd_xxx,		/* reserved */
10157750Storek 		bd_blh,		/* block length (MSB) */
10257750Storek 		bd_blm,		/* block length */
10357750Storek 		bd_bll;		/* block length (LSB) */
10457750Storek };
10559534Storek struct scsi_ms_page_hdr {	/* mode sense/select page header */
10657750Storek 	u_char	mp_psc,		/* saveable flag + code */
10759534Storek 		mp_len;		/* parameter length (excludes this header) */
10859534Storek 		/* followed by parameters */
10957750Storek };
11057750Storek #define	SCSI_MS_MP_SAVEABLE	0x80	/* page can be saved */
11157750Storek /*				0x40	   reserved */
11257750Storek #define	SCSI_MS_PC_MASK		0x3f	/* page code mask */
11357750Storek 
11457750Storek /*
11557750Storek  * Structure of returned mode sense6 / mode select6 (hence "ms6") data.
11657750Storek  */
11757750Storek struct scsi_ms6 {
11854877Storek 	u_char	ms_len,		/* total sense data length */
11957750Storek 		ms_mt,		/* medium type (disks only?) */
12057750Storek 		ms_dsp,		/* device specific parameter */
12157750Storek 		ms_bdl;		/* block descriptor length (bytes) */
12259534Storek 	/* followed by block descriptors, if any */
12357750Storek 	/* followed by pages, if any */
12454877Storek };
12557750Storek /*
12657750Storek  * Same, but for ms10.
12757750Storek  */
12857750Storek struct scsi_ms10 {
12957750Storek 	u_char	ms_lenh,	/* total sense length (MSB) */
13057750Storek 		ms_lenl,	/* total sense length (LSB) */
13157750Storek 		ms_mt,		/* medium type (disks only?) */
13257750Storek 		ms_dsp,		/* device specific parameter */
13357750Storek 		ms_xxx[2],	/* reserved */
13457750Storek 		ms_bdlh,	/* block descriptor length (bytes) (MSB) */
13557750Storek 		ms_bdll;	/* block descriptor length (bytes) (LSB) */
13659534Storek 	/* followed by block descriptors, if any */
13757750Storek 	/* followed by pages, if any */
13857750Storek };
13954877Storek 
14057750Storek /* values for the Medium Type field - disks */
14157750Storek #define	SCSI_MS_MT_DEFAULT	0x00	/* whatever is current */
14257750Storek #define	SCSI_MS_MT_SS		0x01	/* single sided, unspecified medium */
14357750Storek #define	SCSI_MS_MT_DS		0x02	/* double sided, unspecified medium */
14457750Storek #define	SCSI_MS_MT_8SSSD	0x05	/* 8" floppy, SSSD (X3.73-1980) */
14557750Storek #define	SCSI_MS_MT_8DSSD	0x06	/* 8" floppy, DSSD (X3B8-140) */
14657750Storek #define	SCSI_MS_MT_8SSDD	0x09	/* 8" floppy, SSDD (X3B8/78-139) */
14757750Storek #define	SCSI_MS_MT_8DSDD	0x0a	/* 8" floppy, DSDD (X3.121-1984) */
14857750Storek #define	SCSI_MS_MT_5SSSD	0x0d	/* 5.25" floppy, SSSD (X3.82-1980) */
14957750Storek #define	SCSI_MS_MT_5DSDD	0x12	/* 5.25" floppy, DSDD (X3.125-1984) */
15057750Storek #define	SCSI_MS_MT_5DSDD96	0x16	/* 5.25", DSDD, 96tpi (X3.126-198X) */
15157750Storek #define	SCSI_MS_MT_5DSQD	0x1a	/* 5.25", DSQD, 96tpi (DIS 8630) */
15257750Storek #define	SCSI_MS_MT_3DS		0x1e	/* 3.5", double sided (X3.137-198X) */
15357750Storek 
15457750Storek /* values for the Medium Type field - tapes */
15557750Storek #define	SCSI_MS_MT_QIC_12T	0x40	/* 0.25", 12 tracks */
15657750Storek #define	SCSI_MS_MT_QIC_24T	0x44	/* 0.25", 24 tracks */
15757750Storek 
15857750Storek /* values for the Device Specific Parameter field */
15957750Storek #define	SCSI_MS_DSP_WP		0x80	/* write protect (both disk & tape) */
16057750Storek 
16157750Storek 	/* if disk */
16257750Storek #define	SCSI_MS_DSP_DPO_FUA	0x10	/* cache flags DPO, FUA supported */
16357750Storek 
16457750Storek 	/* if tape */
16557750Storek #define	SCSI_MS_DSP_UNBUFFERED	0x00	/* unbuffered writes */
16657750Storek #define	SCSI_MS_DSP_BUFFERED	0x10	/* buffered writes */
16757750Storek #define	SCSI_MS_DSP_BUF2	0x20	/* buffered, for shared tapes */
16857750Storek /*				0x30..0x70 reserved */
16957750Storek #define	SCSI_MS_DSP_SPEED_DFLT	0x00	/* use device default speed */
17057750Storek #define	SCSI_MS_DSP_SPEED_MASK	0x0f	/* mask for non-default speeds */
17157750Storek 
17257750Storek /* values for the Density Code field - tapes */
17357750Storek #define	SCSI_MS_DC_DEFAULT	0	/* use device default density */
17457750Storek #define	SCSI_MS_DC_9T_800BPI	1	/* 9 track, 800 bpi */
17557750Storek #define	SCSI_MS_DC_9T_1600BPI	2	/* 9 track, 1600 bpi */
17657750Storek #define	SCSI_MS_DC_9T_6250BPI	3	/* 9 track, 6250 bpi */
17757750Storek #define	SCSI_MS_DC_QIC_XX1	4	/* QIC-11? 4 or 9 track, 8000 bpi */
17857750Storek #define	SCSI_MS_DC_QIC_XX2	5	/* QIC-11? 4 or 9 track, 8000 bpi */
17957750Storek #define	SCSI_MS_DC_9T_3200BPI	6	/* 9 track, 3200 bpi */
18057750Storek #define	SCSI_MS_DC_QIC_XX3	7	/* QIC, 4 track, 6400 bpi */
18157750Storek #define	SCSI_MS_DC_CS_XX4	8	/* cassette 4 track, 8000 bpi */
18257750Storek #define	SCSI_MS_DC_HIC_XX5	9	/* half inch cartridge, 18 track */
18357750Storek #define	SCSI_MS_DC_HIC_XX6	10	/* HIC, 22 track, 6667 bpi */
18457750Storek #define	SCSI_MS_DC_QIC_XX7	11	/* QIC, 4 track, 1600 bpi */
18557750Storek #define	SCSI_MS_DC_HIC_XX8	12	/* HIC, 24 track, 12690 bpi */
18657750Storek #define	SCSI_MS_DC_HIC_XX9	13	/* HIC, 24 track, 25380 bpi */
18757750Storek 
18854877Storek /*
18957750Storek  * Common page codes.
19057750Storek  */
19157750Storek /*				0x01	   device specific */
19257750Storek #define	SCSI_MS_PC_DR		0x02	/* disconnect/reconnect control */
19357750Storek /*				0x03..0x08 device specific */
19457750Storek #define	SCSI_MS_PC_PDEV		0x09	/* peripheral device page */
19557750Storek #define	SCSI_MS_PC_CTLMODE	0x0a	/* control mode page */
19657750Storek /*				0x0b..0x1f device specific */
19757750Storek /*				0x20..0x3e vendor specific */
19857750Storek #define	SCSI_MS_PC_ALL		0x3f	/* all pages */
19957750Storek 
20057750Storek /*
20157750Storek  * Structure of a Disconnect/Reconnect Control mode page.
20257750Storek  */
20357750Storek struct scsi_page_dr {
20459534Storek 	u_char	dr_full,	/* buffer full ratio */
20557750Storek 		dr_empty,	/* buffer empty ratio */
20657750Storek 		dr_inacth,	/* bus inactivity timeout (MSB) */
20757750Storek 		dr_inactl,	/* bus inactivity timeout (LSB) */
20857750Storek 		dr_disconh,	/* disconnect time limit (MSB) */
20957750Storek 		dr_disconl,	/* disconnect time limit (LSB) */
21057750Storek 		dr_conh,	/* connect time limit (MSB) */
21157750Storek 		dr_conl,	/* connect time limit (LSB) */
21257750Storek 		dr_bursth,	/* maximum burst size (MSB) */
21357750Storek 		dr_burstl,	/* maximum burst size (LSB) */
21457750Storek 		dr_dtdc,	/* Data Transfer Disconnect Control (below) */
21557750Storek 		dr_xxx[3];	/* reserved */
21657750Storek };
21757750Storek /* Data Transfer Disconnect Control */
21857750Storek #define	SCSI_DR_DTDC_MASK	0x03	/* mask for valid bits */
21957750Storek #define	SCSI_DR_DTDC_NONE	0x00	/* no control */
22057750Storek #define	SCSI_DR_DTDC_NOTDATA	0x01	/* never during data transfer */
22157750Storek #define	SCSI_DR_DTDC_RSVD	0x02	/* reserved */
22257750Storek #define	SCSI_DR_DTDC_NOTD2	0x03	/* never during/after data transfer */
22357750Storek 
22457750Storek /*
22554877Storek  * Structure of a PREVENT/ALLOW MEDIUM REMOVAL command.
22654877Storek  */
22754877Storek struct scsi_cdb_pamr {
22854877Storek 	u_char	cdb_cmd,	/* 0x1e */
22957750Storek 		cdb_lun_xxx,	/* logical unit number + reserved */
23054877Storek 		cdb_xxx1,	/* reserved */
23154877Storek 		cdb_xxx2,	/* reserved */
23254877Storek 		cdb_prevent,	/* 1=prevent, 0=allow */
23354877Storek 		cdb_ctrl;
23454877Storek };
235