Home | History | Annotate | Line # | Download | only in scsipi
scsi_all.h revision 1.2.3.1
      1      1.1      cgd /*
      2      1.2      cgd  * SCSI general  interface description
      3  1.2.3.1  mycroft  */
      4  1.2.3.1  mycroft 
      5  1.2.3.1  mycroft /*
      6      1.1      cgd  * Largely written by Julian Elischer (julian (at) tfs.com)
      7      1.1      cgd  * for TRW Financial Systems.
      8      1.1      cgd  *
      9      1.1      cgd  * TRW Financial Systems, in accordance with their agreement with Carnegie
     10      1.1      cgd  * Mellon University, makes this software available to CMU to distribute
     11      1.1      cgd  * or use in any manner that they see fit as long as this message is kept with
     12      1.1      cgd  * the software. For this reason TFS also grants any other persons or
     13      1.1      cgd  * organisations permission to use or modify this software.
     14      1.1      cgd  *
     15      1.1      cgd  * TFS supplies this software to be publicly redistributed
     16      1.1      cgd  * on the understanding that TFS is not responsible for the correct
     17      1.1      cgd  * functioning of this software in any circumstances.
     18      1.1      cgd  *
     19  1.2.3.1  mycroft  * Ported to run under 386BSD by Julian Elischer (julian (at) tfs.com) Sept 1992
     20  1.2.3.1  mycroft  *
     21  1.2.3.1  mycroft  *	$Id: scsi_all.h,v 1.2.3.1 1993/11/24 05:03:00 mycroft Exp $
     22      1.1      cgd  */
     23      1.1      cgd 
     24  1.2.3.1  mycroft #ifndef	_SCSI_SCSI_ALL_H
     25  1.2.3.1  mycroft #define _SCSI_SCSI_ALL_H 1
     26      1.1      cgd /*
     27  1.2.3.1  mycroft  * SCSI command format
     28      1.1      cgd  */
     29      1.1      cgd 
     30      1.1      cgd /*
     31  1.2.3.1  mycroft  * Define dome bits that are in ALL (or a lot of) scsi commands
     32      1.1      cgd  */
     33  1.2.3.1  mycroft #define SCSI_CTL_LINK		0x01
     34  1.2.3.1  mycroft #define SCSI_CTL_FLAG		0x02
     35  1.2.3.1  mycroft #define SCSI_CTL_VENDOR		0xC0
     36  1.2.3.1  mycroft #define	SCSI_CMD_LUN		0xA0	/* these two should not be needed */
     37  1.2.3.1  mycroft #define	SCSI_CMD_LUN_SHIFT	5	/* LUN in the cmd is no longer SCSI */
     38      1.1      cgd 
     39      1.1      cgd 
     40      1.1      cgd struct scsi_generic
     41      1.1      cgd {
     42      1.1      cgd 	u_char	opcode;
     43      1.1      cgd 	u_char	bytes[11];
     44      1.1      cgd };
     45      1.1      cgd 
     46      1.1      cgd struct scsi_test_unit_ready
     47      1.1      cgd {
     48      1.1      cgd 	u_char	op_code;
     49  1.2.3.1  mycroft 	u_char	byte2;
     50      1.1      cgd 	u_char	unused[3];
     51  1.2.3.1  mycroft 	u_char	control;
     52      1.1      cgd };
     53      1.1      cgd 
     54      1.1      cgd struct scsi_send_diag
     55      1.1      cgd {
     56      1.1      cgd 	u_char	op_code;
     57  1.2.3.1  mycroft 	u_char	byte2;
     58  1.2.3.1  mycroft #define	SSD_UOL		0x01
     59  1.2.3.1  mycroft #define	SSD_DOL		0x02
     60  1.2.3.1  mycroft #define	SSD_SELFTEST	0x04
     61  1.2.3.1  mycroft #define	SSD_PF		0x10
     62      1.1      cgd 	u_char	unused[1];
     63      1.1      cgd 	u_char	paramlen[2];
     64  1.2.3.1  mycroft 	u_char	control;
     65      1.1      cgd };
     66      1.1      cgd 
     67      1.1      cgd struct scsi_sense
     68      1.1      cgd {
     69      1.1      cgd 	u_char	op_code;
     70  1.2.3.1  mycroft 	u_char	byte2;
     71      1.1      cgd 	u_char	unused[2];
     72      1.1      cgd 	u_char	length;
     73  1.2.3.1  mycroft 	u_char	control;
     74      1.1      cgd };
     75      1.1      cgd 
     76      1.1      cgd struct scsi_inquiry
     77      1.1      cgd {
     78      1.1      cgd 	u_char	op_code;
     79  1.2.3.1  mycroft 	u_char	byte2;
     80      1.1      cgd 	u_char	unused[2];
     81      1.1      cgd 	u_char	length;
     82  1.2.3.1  mycroft 	u_char	control;
     83      1.1      cgd };
     84      1.1      cgd 
     85      1.1      cgd struct scsi_mode_sense
     86      1.1      cgd {
     87      1.1      cgd 	u_char	op_code;
     88  1.2.3.1  mycroft 	u_char	byte2;
     89  1.2.3.1  mycroft #define	SMS_DBD				0x08
     90  1.2.3.1  mycroft 	u_char	page;
     91  1.2.3.1  mycroft #define	SMS_PAGE_CODE 			0x3F
     92  1.2.3.1  mycroft #define	SMS_PAGE_CTRL 			0xC0
     93  1.2.3.1  mycroft #define	SMS_PAGE_CTRL_CURRENT 		0x00
     94  1.2.3.1  mycroft #define	SMS_PAGE_CTRL_CHANGEABLE 	0x40
     95  1.2.3.1  mycroft #define	SMS_PAGE_CTRL_DEFAULT 		0x80
     96  1.2.3.1  mycroft #define	SMS_PAGE_CTRL_SAVED 		0xC0
     97      1.1      cgd 	u_char	unused;
     98      1.1      cgd 	u_char	length;
     99  1.2.3.1  mycroft 	u_char	control;
    100      1.1      cgd };
    101      1.1      cgd 
    102      1.1      cgd struct scsi_mode_sense_big
    103      1.1      cgd {
    104      1.1      cgd 	u_char	op_code;
    105  1.2.3.1  mycroft 	u_char	byte2; 		/* same bits as small version */
    106  1.2.3.1  mycroft 	u_char	page; 		/* same bits as small version */
    107      1.1      cgd 	u_char	unused[4];
    108      1.1      cgd 	u_char	length[2];
    109  1.2.3.1  mycroft 	u_char	control;
    110      1.1      cgd };
    111      1.1      cgd 
    112      1.1      cgd struct scsi_mode_select
    113      1.1      cgd {
    114      1.1      cgd 	u_char	op_code;
    115  1.2.3.1  mycroft 	u_char	byte2;
    116  1.2.3.1  mycroft #define	SMS_SP	0x01
    117  1.2.3.1  mycroft #define	SMS_PF	0x10
    118      1.1      cgd 	u_char	unused[2];
    119      1.1      cgd 	u_char	length;
    120  1.2.3.1  mycroft 	u_char	control;
    121      1.1      cgd };
    122      1.1      cgd 
    123      1.1      cgd struct scsi_mode_select_big
    124      1.1      cgd {
    125      1.1      cgd 	u_char	op_code;
    126  1.2.3.1  mycroft 	u_char	byte2;		/* same bits as small version */
    127      1.1      cgd 	u_char	unused[5];
    128      1.1      cgd 	u_char	length[2];
    129  1.2.3.1  mycroft 	u_char	control;
    130      1.1      cgd };
    131      1.1      cgd 
    132      1.1      cgd struct scsi_reserve
    133      1.1      cgd {
    134      1.1      cgd 	u_char	op_code;
    135  1.2.3.1  mycroft 	u_char	byte2;
    136      1.1      cgd 	u_char	unused[2];
    137      1.1      cgd 	u_char	length;
    138  1.2.3.1  mycroft 	u_char	control;
    139      1.1      cgd };
    140      1.1      cgd 
    141      1.1      cgd struct scsi_release
    142      1.1      cgd {
    143      1.1      cgd 	u_char	op_code;
    144  1.2.3.1  mycroft 	u_char	byte2;
    145      1.1      cgd 	u_char	unused[2];
    146      1.1      cgd 	u_char	length;
    147  1.2.3.1  mycroft 	u_char	control;
    148      1.1      cgd };
    149      1.1      cgd 
    150      1.1      cgd struct scsi_prevent
    151      1.1      cgd {
    152      1.1      cgd 	u_char	op_code;
    153  1.2.3.1  mycroft 	u_char	byte2;
    154      1.1      cgd 	u_char	unused[2];
    155  1.2.3.1  mycroft 	u_char	how;
    156  1.2.3.1  mycroft 	u_char	control;
    157      1.1      cgd };
    158  1.2.3.1  mycroft #define	PR_PREVENT 0x01
    159  1.2.3.1  mycroft #define PR_ALLOW   0x00
    160  1.2.3.1  mycroft 
    161  1.2.3.1  mycroft struct scsi_changedef
    162  1.2.3.1  mycroft {
    163  1.2.3.1  mycroft 	u_char	op_code;
    164  1.2.3.1  mycroft 	u_char	byte2;
    165  1.2.3.1  mycroft 	u_char	unused1;
    166  1.2.3.1  mycroft 	u_char	how;
    167  1.2.3.1  mycroft 	u_char	unused[4];
    168  1.2.3.1  mycroft 	u_char	datalen;
    169  1.2.3.1  mycroft 	u_char	control;
    170  1.2.3.1  mycroft };
    171  1.2.3.1  mycroft #define SC_SCSI_1 0x01
    172  1.2.3.1  mycroft #define SC_SCSI_2 0x03
    173      1.1      cgd 
    174      1.1      cgd /*
    175      1.1      cgd  * Opcodes
    176      1.1      cgd  */
    177      1.1      cgd 
    178      1.1      cgd #define	TEST_UNIT_READY		0x00
    179      1.1      cgd #define REQUEST_SENSE		0x03
    180      1.1      cgd #define INQUIRY			0x12
    181      1.1      cgd #define MODE_SELECT		0x15
    182      1.1      cgd #define MODE_SENSE		0x1a
    183      1.1      cgd #define START_STOP		0x1b
    184      1.1      cgd #define RESERVE      		0x16
    185      1.1      cgd #define RELEASE      		0x17
    186      1.1      cgd #define PREVENT_ALLOW		0x1e
    187      1.1      cgd #define POSITION_TO_ELEMENT	0x2b
    188  1.2.3.1  mycroft #define	CHANGE_DEFINITION	0x40
    189      1.1      cgd #define	MODE_SENSE_BIG		0x54
    190      1.1      cgd #define	MODE_SELECT_BIG		0x55
    191      1.1      cgd #define MOVE_MEDIUM     	0xa5
    192      1.1      cgd #define READ_ELEMENT_STATUS	0xb8
    193      1.1      cgd 
    194      1.1      cgd 
    195      1.1      cgd /*
    196      1.1      cgd  * sense data format
    197      1.1      cgd  */
    198      1.1      cgd #define T_DIRECT	0
    199      1.1      cgd #define T_SEQUENTIAL	1
    200      1.1      cgd #define T_PRINTER	2
    201      1.1      cgd #define T_PROCESSOR	3
    202      1.1      cgd #define T_WORM		4
    203      1.1      cgd #define T_READONLY	5
    204      1.1      cgd #define T_SCANNER 	6
    205      1.1      cgd #define T_OPTICAL 	7
    206      1.1      cgd #define T_NODEVICE	0x1F
    207      1.1      cgd 
    208      1.1      cgd #define T_CHANGER	8
    209      1.1      cgd #define T_COMM		9
    210      1.1      cgd 
    211      1.1      cgd #define T_REMOV		1
    212      1.1      cgd #define	T_FIXED		0
    213      1.1      cgd 
    214      1.1      cgd struct scsi_inquiry_data
    215      1.1      cgd {
    216  1.2.3.1  mycroft 	u_char	device;
    217  1.2.3.1  mycroft #define	SID_TYPE	0x1F
    218  1.2.3.1  mycroft #define	SID_QUAL	0xE0
    219  1.2.3.1  mycroft #define	SID_QUAL_LU_OK	0x00
    220  1.2.3.1  mycroft #define	SID_QUAL_LU_OFFLINE	0x20
    221  1.2.3.1  mycroft #define	SID_QUAL_RSVD	0x40
    222  1.2.3.1  mycroft #define	SID_QUAL_BAD_LU	0x60
    223  1.2.3.1  mycroft 	u_char	dev_qual2;
    224  1.2.3.1  mycroft #define	SID_QUAL2	0x7F
    225  1.2.3.1  mycroft #define	SID_REMOVABLE	0x80
    226  1.2.3.1  mycroft 	u_char	version;
    227  1.2.3.1  mycroft #define SID_ANSII	0x07
    228  1.2.3.1  mycroft #define SID_ECMA	0x38
    229  1.2.3.1  mycroft #define SID_ISO		0xC0
    230      1.1      cgd 	u_char	response_format;
    231      1.1      cgd 	u_char	additional_length;
    232      1.1      cgd 	u_char	unused[2];
    233  1.2.3.1  mycroft 	u_char	flags;
    234  1.2.3.1  mycroft #define	SID_SftRe	0x01
    235  1.2.3.1  mycroft #define	SID_CmdQue	0x02
    236  1.2.3.1  mycroft #define	SID_Linked	0x08
    237  1.2.3.1  mycroft #define	SID_Sync	0x10
    238  1.2.3.1  mycroft #define	SID_WBus16	0x20
    239  1.2.3.1  mycroft #define	SID_WBus32	0x40
    240  1.2.3.1  mycroft #define	SID_RelAdr	0x80
    241      1.1      cgd 	char	vendor[8];
    242      1.1      cgd 	char	product[16];
    243      1.1      cgd 	char	revision[4];
    244      1.1      cgd 	u_char	extra[8];
    245      1.1      cgd };
    246      1.1      cgd 
    247      1.1      cgd 
    248      1.1      cgd struct	scsi_sense_data
    249      1.1      cgd {
    250  1.2.3.1  mycroft /* 1*/	u_char	error_code;	/* same bits as new version */
    251      1.1      cgd 	union
    252      1.1      cgd 	{
    253      1.1      cgd 		struct
    254      1.1      cgd 		{
    255  1.2.3.1  mycroft /* 2*/			u_char	blockhi;
    256  1.2.3.1  mycroft /* 3*/			u_char	blockmed;
    257  1.2.3.1  mycroft /* 4*/			u_char	blocklow;
    258      1.1      cgd 		} unextended;
    259      1.1      cgd 		struct
    260      1.1      cgd 		{
    261  1.2.3.1  mycroft /* 2*/			u_char	segment;
    262  1.2.3.1  mycroft /* 3*/			u_char	flags;	/* same bits as new version */
    263  1.2.3.1  mycroft /* 7*/			u_char	info[4];
    264  1.2.3.1  mycroft /* 8*/			u_char	extra_len;
    265      1.1      cgd 			/* allocate enough room to hold new stuff
    266  1.2.3.1  mycroft 			( by increasing 16 to 24 below) */
    267  1.2.3.1  mycroft /*32*/			u_char	extra_bytes[24];
    268      1.1      cgd 		} extended;
    269      1.1      cgd 	}ext;
    270  1.2.3.1  mycroft };	/* total of 32 bytes */
    271      1.1      cgd struct	scsi_sense_data_new
    272      1.1      cgd {
    273  1.2.3.1  mycroft /* 1*/	u_char	error_code;
    274  1.2.3.1  mycroft #define	SSD_ERRCODE		0x7F
    275  1.2.3.1  mycroft #define	SSD_ERRCODE_VALID	0x80
    276      1.1      cgd 	union
    277      1.1      cgd 	{
    278  1.2.3.1  mycroft 		struct	/* this is deprecated, the standard says "DON'T"*/
    279      1.1      cgd 		{
    280  1.2.3.1  mycroft /* 2*/			u_char	blockhi;
    281  1.2.3.1  mycroft /* 3*/			u_char	blockmed;
    282  1.2.3.1  mycroft /* 4*/			u_char	blocklow;
    283      1.1      cgd 		} unextended;
    284      1.1      cgd 		struct
    285      1.1      cgd 		{
    286  1.2.3.1  mycroft /* 2*/			u_char	segment;
    287  1.2.3.1  mycroft /* 3*/			u_char	flags;
    288  1.2.3.1  mycroft #define	SSD_KEY		0x0F
    289  1.2.3.1  mycroft #define	SSD_ILI		0x20
    290  1.2.3.1  mycroft #define	SSD_EOM		0x40
    291  1.2.3.1  mycroft #define	SSD_FILEMARK	0x80
    292  1.2.3.1  mycroft /* 7*/			u_char	info[4];
    293  1.2.3.1  mycroft /* 8*/			u_char	extra_len;
    294  1.2.3.1  mycroft /*12*/			u_char	cmd_spec_info[4];
    295  1.2.3.1  mycroft /*13*/			u_char	add_sense_code;
    296  1.2.3.1  mycroft /*14*/			u_char	add_sense_code_qual;
    297  1.2.3.1  mycroft /*15*/			u_char	fru;
    298  1.2.3.1  mycroft /*16*/			u_char	sense_key_spec_1;
    299  1.2.3.1  mycroft #define	SSD_SCS_VALID		0x80
    300  1.2.3.1  mycroft /*17*/			u_char	sense_key_spec_2;
    301  1.2.3.1  mycroft /*18*/			u_char	sense_key_spec_3;
    302  1.2.3.1  mycroft /*32*/			u_char	extra_bytes[14];
    303      1.1      cgd 		} extended;
    304      1.1      cgd 	}ext;
    305  1.2.3.1  mycroft }; /* total of 32 bytes */
    306      1.1      cgd 
    307      1.1      cgd struct	blk_desc
    308      1.1      cgd {
    309      1.1      cgd 	u_char	density;
    310      1.1      cgd 	u_char	nblocks[3];
    311      1.1      cgd 	u_char	reserved;
    312      1.1      cgd 	u_char	blklen[3];
    313      1.1      cgd };
    314      1.1      cgd 
    315      1.1      cgd struct scsi_mode_header
    316      1.1      cgd {
    317      1.1      cgd 	u_char	data_length;	/* Sense data length */
    318      1.1      cgd 	u_char	medium_type;
    319      1.1      cgd 	u_char	dev_spec;
    320      1.1      cgd 	u_char	blk_desc_len;
    321      1.1      cgd };
    322      1.1      cgd 
    323      1.1      cgd struct scsi_mode_header_big
    324      1.1      cgd {
    325      1.1      cgd 	u_char	data_length[2];	/* Sense data length */
    326      1.1      cgd 	u_char	medium_type;
    327      1.1      cgd 	u_char	dev_spec;
    328      1.1      cgd 	u_char	unused[2];
    329      1.1      cgd 	u_char	blk_desc_len[2];
    330      1.1      cgd };
    331      1.1      cgd 
    332      1.1      cgd 
    333      1.1      cgd /*
    334      1.1      cgd  * Status Byte
    335      1.1      cgd  */
    336      1.1      cgd #define	SCSI_OK		0x00
    337      1.1      cgd #define	SCSI_CHECK		0x02
    338      1.1      cgd #define	SCSI_BUSY		0x08
    339      1.1      cgd #define SCSI_INTERM		0x10
    340  1.2.3.1  mycroft #endif /*_SCSI_SCSI_ALL_H*/
    341