[BACK]Return to scsi_all.h CVS log [TXT][DIR] Up to [local] / sys / scsi

Annotation of sys/scsi/scsi_all.h, Revision 1.1

1.1     ! nbrk        1: /*     $OpenBSD: scsi_all.h,v 1.43 2007/04/12 16:33:27 weingart Exp $  */
        !             2: /*     $NetBSD: scsi_all.h,v 1.10 1996/09/12 01:57:17 thorpej Exp $    */
        !             3:
        !             4: /*
        !             5:  * SCSI general  interface description
        !             6:  */
        !             7:
        !             8: /*
        !             9:  * Largely written by Julian Elischer (julian@tfs.com)
        !            10:  * for TRW Financial Systems.
        !            11:  *
        !            12:  * TRW Financial Systems, in accordance with their agreement with Carnegie
        !            13:  * Mellon University, makes this software available to CMU to distribute
        !            14:  * or use in any manner that they see fit as long as this message is kept with
        !            15:  * the software. For this reason TFS also grants any other persons or
        !            16:  * organisations permission to use or modify this software.
        !            17:  *
        !            18:  * TFS supplies this software to be publicly redistributed
        !            19:  * on the understanding that TFS is not responsible for the correct
        !            20:  * functioning of this software in any circumstances.
        !            21:  *
        !            22:  * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
        !            23:  */
        !            24:
        !            25: #ifndef        _SCSI_SCSI_ALL_H
        !            26: #define _SCSI_SCSI_ALL_H 1
        !            27:
        !            28: /*
        !            29:  * SCSI command format
        !            30:  */
        !            31:
        !            32: /*
        !            33:  * Define some bits that are in ALL (or a lot of) scsi commands
        !            34:  */
        !            35: #define SCSI_CTL_LINK          0x01
        !            36: #define SCSI_CTL_FLAG          0x02
        !            37: #define SCSI_CTL_VENDOR                0xC0
        !            38:
        !            39:
        !            40: /*
        !            41:  * Some old SCSI devices need the LUN to be set in the top 3 bits of the
        !            42:  * second byte of the CDB.
        !            43:  */
        !            44: #define        SCSI_CMD_LUN_MASK       0xe0
        !            45: #define        SCSI_CMD_LUN_SHIFT      5
        !            46:
        !            47:
        !            48: struct scsi_generic {
        !            49:        u_int8_t opcode;
        !            50:        u_int8_t bytes[15];
        !            51: };
        !            52:
        !            53: struct scsi_test_unit_ready {
        !            54:        u_int8_t opcode;
        !            55:        u_int8_t byte2;
        !            56:        u_int8_t unused[3];
        !            57:        u_int8_t control;
        !            58: };
        !            59:
        !            60: struct scsi_send_diag {
        !            61:        u_int8_t opcode;
        !            62:        u_int8_t byte2;
        !            63: #define        SSD_UOL         0x01
        !            64: #define        SSD_DOL         0x02
        !            65: #define        SSD_SELFTEST    0x04
        !            66: #define        SSD_PF          0x10
        !            67:        u_int8_t unused[1];
        !            68:        u_int8_t paramlen[2];
        !            69:        u_int8_t control;
        !            70: };
        !            71:
        !            72: struct scsi_sense {
        !            73:        u_int8_t opcode;
        !            74:        u_int8_t byte2;
        !            75:        u_int8_t unused[2];
        !            76:        u_int8_t length;
        !            77:        u_int8_t control;
        !            78: };
        !            79:
        !            80: struct scsi_inquiry {
        !            81:        u_int8_t opcode;
        !            82:        u_int8_t flags;
        !            83: #define SI_EVPD                0x01
        !            84:        u_int8_t pagecode;
        !            85: #define SI_PG_SERIAL   0x80
        !            86:        u_int8_t length[2];
        !            87:        u_int8_t control;
        !            88: };
        !            89:
        !            90: struct scsi_mode_sense {
        !            91:        u_int8_t opcode;
        !            92:        u_int8_t byte2;
        !            93: #define        SMS_DBD                         0x08    /* Disable Block Descriptors */
        !            94:        u_int8_t page;
        !            95: #define        SMS_PAGE_CODE                   0x3F
        !            96: #define        SMS_PAGE_CTRL                   0xC0
        !            97: #define        SMS_PAGE_CTRL_CURRENT           0x00
        !            98: #define        SMS_PAGE_CTRL_CHANGEABLE        0x40
        !            99: #define        SMS_PAGE_CTRL_DEFAULT           0x80
        !           100: #define        SMS_PAGE_CTRL_SAVED             0xC0
        !           101:        u_int8_t unused;
        !           102:        u_int8_t length;
        !           103:        u_int8_t control;
        !           104: };
        !           105:
        !           106: struct scsi_mode_sense_big {
        !           107:        u_int8_t opcode;
        !           108:        u_int8_t byte2;                         /* same bits as small version */
        !           109: #define SMS_LLBAA                      0x10    /*    plus: Long LBA Accepted */
        !           110:        u_int8_t page;                          /* same bits as small version */
        !           111:        u_int8_t unused[4];
        !           112:        u_int8_t length[2];
        !           113:        u_int8_t control;
        !           114: };
        !           115:
        !           116: struct scsi_mode_select {
        !           117:        u_int8_t opcode;
        !           118:        u_int8_t byte2;
        !           119: #define        SMS_SP  0x01
        !           120: #define        SMS_PF  0x10
        !           121:        u_int8_t unused[2];
        !           122:        u_int8_t length;
        !           123:        u_int8_t control;
        !           124: };
        !           125:
        !           126: struct scsi_mode_select_big {
        !           127:        u_int8_t opcode;
        !           128:        u_int8_t byte2;         /* same bits as small version */
        !           129:        u_int8_t unused[5];
        !           130:        u_int8_t length[2];
        !           131:        u_int8_t control;
        !           132: };
        !           133:
        !           134: struct scsi_reserve {
        !           135:        u_int8_t opcode;
        !           136:        u_int8_t byte2;
        !           137:        u_int8_t unused[2];
        !           138:        u_int8_t length;
        !           139:        u_int8_t control;
        !           140: };
        !           141:
        !           142: struct scsi_release {
        !           143:        u_int8_t opcode;
        !           144:        u_int8_t byte2;
        !           145:        u_int8_t unused[2];
        !           146:        u_int8_t length;
        !           147:        u_int8_t control;
        !           148: };
        !           149:
        !           150: struct scsi_prevent {
        !           151:        u_int8_t opcode;
        !           152:        u_int8_t byte2;
        !           153:        u_int8_t unused[2];
        !           154:        u_int8_t how;
        !           155:        u_int8_t control;
        !           156: };
        !           157: #define        PR_PREVENT 0x01
        !           158: #define PR_ALLOW   0x00
        !           159:
        !           160: struct scsi_report_luns {
        !           161:        u_int8_t opcode;
        !           162:        u_int8_t unused;
        !           163:        u_int8_t selectreport;
        !           164: #define        REPORT_NORMAL           0x00
        !           165: #define        REPORT_WELLKNOWN        0x01
        !           166: #define        REPORT_ALL              0x02
        !           167:        u_int8_t unused2[3];
        !           168:        u_int8_t length[4];
        !           169:        u_int8_t unused4;
        !           170:        u_int8_t control;
        !           171: };
        !           172:
        !           173: /*
        !           174:  * Opcodes
        !           175:  */
        !           176: #define        TEST_UNIT_READY         0x00
        !           177: #define REQUEST_SENSE          0x03
        !           178: #define INQUIRY                        0x12
        !           179: #define MODE_SELECT            0x15
        !           180: #define RESERVE                        0x16
        !           181: #define RELEASE                        0x17
        !           182: #define MODE_SENSE             0x1a
        !           183: #define START_STOP             0x1b
        !           184: #define RECEIVE_DIAGNOSTIC     0x1c
        !           185: #define SEND_DIAGNOSTIC                0x1d
        !           186: #define PREVENT_ALLOW          0x1e
        !           187: #define POSITION_TO_ELEMENT    0x2b
        !           188: #define WRITE_BUFFER           0x3b
        !           189: #define READ_BUFFER            0x3c
        !           190: #define        CHANGE_DEFINITION       0x40
        !           191: #define        MODE_SELECT_BIG         0x55
        !           192: #define        MODE_SENSE_BIG          0x5a
        !           193: #define        REPORT_LUNS             0xa0
        !           194:
        !           195: /*
        !           196:  * Sort of an extra one, for SCSI_RESET.
        !           197:  */
        !           198: #define GENRETRY               1
        !           199:
        !           200: /*
        !           201:  * sense data format
        !           202:  */
        !           203: #define T_DIRECT       0
        !           204: #define T_SEQUENTIAL   1
        !           205: #define T_PRINTER      2
        !           206: #define T_PROCESSOR    3
        !           207: #define T_WORM         4
        !           208: #define T_CDROM                5
        !           209: #define T_SCANNER      6
        !           210: #define T_OPTICAL      7
        !           211: #define T_RDIRECT      14
        !           212: #define T_NODEVICE     0x1F
        !           213:
        !           214: #define T_CHANGER      8
        !           215: #define T_COMM         9
        !           216: #define        T_ENCLOSURE     13
        !           217:
        !           218: #define T_REMOV                1
        !           219: #define        T_FIXED         0
        !           220:
        !           221: struct scsi_inquiry_data {
        !           222:        u_int8_t device;
        !           223: #define        SID_TYPE        0x1F
        !           224: #define        SID_QUAL        0xE0
        !           225: #define        SID_QUAL_LU_OK  0x00
        !           226: #define        SID_QUAL_LU_OFFLINE     0x20
        !           227: #define        SID_QUAL_RSVD   0x40
        !           228: #define        SID_QUAL_BAD_LU 0x60
        !           229:        u_int8_t dev_qual2;
        !           230: #define        SID_QUAL2       0x7F
        !           231: #define        SID_REMOVABLE   0x80
        !           232:        u_int8_t version;
        !           233: #define SID_ANSII      0x07
        !           234: #define SID_ECMA       0x38
        !           235: #define SID_ISO                0xC0
        !           236:        u_int8_t response_format;
        !           237:        u_int8_t additional_length;
        !           238: #define SID_INQUIRY_HDR        5       /* Bytes up to & including additional_length */
        !           239: #define SID_SCSI2_ALEN 31      /* Additional bytes of basic SCSI2 info */
        !           240:        u_int8_t unused[2];
        !           241:        u_int8_t flags;
        !           242: #define        SID_SftRe       0x01
        !           243: #define        SID_CmdQue      0x02
        !           244: #define        SID_Linked      0x08
        !           245: #define        SID_Sync        0x10
        !           246: #define        SID_WBus16      0x20
        !           247: #define        SID_WBus32      0x40
        !           248: #define        SID_RelAdr      0x80
        !           249:        char    vendor[8];
        !           250:        char    product[16];
        !           251:        char    revision[4];
        !           252:        u_int8_t extra[20];
        !           253:        u_int8_t flags2;
        !           254: #define SID_IUS                0x01
        !           255: #define SID_QAS                0x02
        !           256: #define SID_CLOCKING   0x0c /* 0 == ST only, 1 == DT only, 3 == both */
        !           257:        u_int8_t reserved;
        !           258: };
        !           259:
        !           260: struct scsi_inquiry_vpd {
        !           261:        u_int8_t device;
        !           262:        u_int8_t page_code;
        !           263:        u_int8_t reserved;
        !           264:        u_int8_t page_length;
        !           265:        char serial[32];
        !           266: };
        !           267:
        !           268: struct scsi_sense_data_unextended {
        !           269: /* 1*/ u_int8_t error_code;
        !           270: /* 4*/ u_int8_t block[3];
        !           271: };
        !           272:
        !           273: struct scsi_sense_data {
        !           274: /* 1*/ u_int8_t error_code;
        !           275: #define        SSD_ERRCODE_CURRENT     0x70
        !           276: #define        SSD_ERRCODE_DEFERRED    0x71
        !           277: #define        SSD_ERRCODE             0x7F
        !           278: #define        SSD_ERRCODE_VALID       0x80
        !           279: /* 2*/ u_int8_t segment;
        !           280: /* 3*/ u_int8_t flags;
        !           281: #define        SSD_KEY         0x0F
        !           282: #define        SSD_ILI         0x20
        !           283: #define        SSD_EOM         0x40
        !           284: #define        SSD_FILEMARK    0x80
        !           285: /* 7*/ u_int8_t info[4];
        !           286: /* 8*/ u_int8_t extra_len;
        !           287: /*12*/ u_int8_t cmd_spec_info[4];
        !           288: /*13*/ u_int8_t add_sense_code;
        !           289: /*14*/ u_int8_t add_sense_code_qual;
        !           290: /*15*/ u_int8_t fru;
        !           291: /*16*/ u_int8_t sense_key_spec_1;
        !           292: #define        SSD_SCS_VALID           0x80
        !           293: #define SSD_SCS_CDB_ERROR      0x40
        !           294: #define SSD_SCS_SEGMENT_DESC   0x20
        !           295: #define SSD_SCS_VALID_BIT_INDEX        0x08
        !           296: #define SSD_SCS_BIT_INDEX      0x07
        !           297: /*17*/ u_int8_t sense_key_spec_2;
        !           298: /*18*/ u_int8_t sense_key_spec_3;
        !           299: /*32*/ u_int8_t extra_bytes[14];
        !           300: };
        !           301:
        !           302: #define SKEY_NO_SENSE          0x00
        !           303: #define SKEY_RECOVERED_ERROR   0x01
        !           304: #define SKEY_NOT_READY         0x02
        !           305: #define SKEY_MEDIUM_ERROR      0x03
        !           306: #define SKEY_HARDWARE_ERROR    0x04
        !           307: #define SKEY_ILLEGAL_REQUEST   0x05
        !           308: #define SKEY_UNIT_ATTENTION    0x06
        !           309: #define SKEY_WRITE_PROTECT     0x07
        !           310: #define SKEY_BLANK_CHECK       0x08
        !           311: #define SKEY_VENDOR_UNIQUE     0x09
        !           312: #define SKEY_COPY_ABORTED      0x0A
        !           313: #define SKEY_ABORTED_COMMAND   0x0B
        !           314: #define SKEY_EQUAL             0x0C
        !           315: #define SKEY_VOLUME_OVERFLOW   0x0D
        !           316: #define SKEY_MISCOMPARE                0x0E
        !           317: #define SKEY_RESERVED          0x0F
        !           318:
        !           319:
        !           320: /* Additional sense code info */
        !           321: #define ASC_ASCQ(ssd)  ((ssd->add_sense_code << 8) | ssd->add_sense_code_qual)
        !           322:
        !           323: #define SENSE_NOT_READY_BECOMING_READY         0x0401
        !           324: #define SENSE_NOT_READY_INIT_REQUIRED          0x0402
        !           325: #define SENSE_NOT_READY_FORMAT                 0x0404
        !           326: #define SENSE_NOT_READY_REBUILD                        0x0405
        !           327: #define SENSE_NOT_READY_RECALC                 0x0406
        !           328: #define SENSE_NOT_READY_INPROGRESS             0x0407
        !           329: #define SENSE_NOT_READY_LONGWRITE              0x0408
        !           330: #define SENSE_NOT_READY_SELFTEST               0x0409
        !           331: #define SENSE_POWER_RESET_OR_BUS               0x2900
        !           332: #define SENSE_POWER_ON                         0x2901
        !           333: #define SENSE_BUS_RESET                                0x2902
        !           334: #define SENSE_BUS_DEVICE_RESET                 0x2903
        !           335: #define SENSE_DEVICE_INTERNAL_RESET            0x2904
        !           336: #define SENSE_TSC_CHANGE_SE                    0x2905
        !           337: #define SENSE_TSC_CHANGE_LVD                   0x2906
        !           338: #define SENSE_IT_NEXUS_LOSS                    0x2907
        !           339: #define SENSE_BAD_MEDIUM                       0x3000
        !           340: #define SENSE_NR_MEDIUM_UNKNOWN_FORMAT         0x3001
        !           341: #define SENSE_NR_MEDIUM_INCOMPATIBLE_FORMAT    0x3002
        !           342: #define SENSE_NW_MEDIUM_UNKNOWN_FORMAT         0x3004
        !           343: #define SENSE_NW_MEDIUM_INCOMPATIBLE_FORMAT    0x3005
        !           344: #define SENSE_NF_MEDIUM_INCOMPATIBLE_FORMAT    0x3006
        !           345: #define SENSE_NW_MEDIUM_AC_MISMATCH            0x3008
        !           346: #define SENSE_NOMEDIUM                         0x3A00
        !           347: #define SENSE_NOMEDIUM_TCLOSED                 0x3A01
        !           348: #define SENSE_NOMEDIUM_TOPEN                   0x3A02
        !           349: #define SENSE_NOMEDIUM_LOADABLE                        0x3A03
        !           350: #define SENSE_NOMEDIUM_AUXMEM                  0x3A04
        !           351: #define SENSE_CARTRIDGE_FAULT                  0x5200
        !           352: #define SENSE_MEDIUM_REMOVAL_PREVENTED         0x5302
        !           353:
        !           354: struct scsi_blk_desc {
        !           355:        u_int8_t density;
        !           356:        u_int8_t nblocks[3];
        !           357:        u_int8_t reserved;
        !           358:        u_int8_t blklen[3];
        !           359: };
        !           360:
        !           361: struct scsi_direct_blk_desc {
        !           362:        u_int8_t nblocks[4];
        !           363:        u_int8_t density;
        !           364:        u_int8_t blklen[3];
        !           365: };
        !           366:
        !           367: struct scsi_blk_desc_big {
        !           368:        u_int8_t nblocks[8];
        !           369:        u_int8_t density;
        !           370:        u_int8_t reserved[3];
        !           371:        u_int8_t blklen[4];
        !           372: };
        !           373:
        !           374: struct scsi_mode_header {
        !           375:        u_int8_t data_length;           /* Sense data length */
        !           376:        u_int8_t medium_type;
        !           377:        u_int8_t dev_spec;
        !           378:        u_int8_t blk_desc_len;
        !           379: };
        !           380:
        !           381: struct scsi_mode_header_big {
        !           382:        u_int8_t data_length[2];        /* Sense data length */
        !           383:        u_int8_t medium_type;
        !           384:        u_int8_t dev_spec;
        !           385:        u_int8_t reserved;
        !           386: #define LONGLBA        0x01
        !           387:        u_int8_t reserved2;
        !           388:        u_int8_t blk_desc_len[2];
        !           389: };
        !           390:
        !           391: union scsi_mode_sense_buf {
        !           392:        struct scsi_mode_header hdr;
        !           393:        struct scsi_mode_header_big hdr_big;
        !           394:        u_char buf[255];        /* 256 bytes breaks some devices. */
        !           395: } __packed;                    /* Ensure sizeof() is 255! */
        !           396:
        !           397: struct scsi_report_luns_data {
        !           398:        u_int8_t length[4];     /* length of LUN inventory, in bytes */
        !           399:        u_int8_t reserved[4];   /* unused */
        !           400:        /*
        !           401:         * LUN inventory- we only support the type zero form for now.
        !           402:         */
        !           403: #define RPL_LUNDATA_SIZE 8     /* Bytes per lun */
        !           404:        struct {
        !           405:                u_int8_t lundata[RPL_LUNDATA_SIZE];
        !           406:        } luns[256];            /* scsi_link->luns is u_int8_t. */
        !           407: };
        !           408: #define        RPL_LUNDATA_T0LUN       1       /* Type 0 LUN is in lundata[1] */
        !           409:
        !           410: /*
        !           411:  * SPI status information unit. See section 14.3.5 of SPI-3.
        !           412:  */
        !           413: struct scsi_status_iu_header {
        !           414: /* 2*/ u_int8_t reserved[2];
        !           415: /* 3*/ u_int8_t flags;
        !           416: #define        SIU_SNSVALID 0x2
        !           417: #define        SIU_RSPVALID 0x1
        !           418: /* 4*/ u_int8_t status;
        !           419: /* 8*/ u_int8_t sense_length[4];
        !           420: /*12*/ u_int8_t pkt_failures_length[4];
        !           421:        u_int8_t data[1]; /* <pkt failure list><sense data> OR <sense_data> */
        !           422: };
        !           423:
        !           424: #define SIU_PKTFAIL_CODE(siu)  ((siu)->data[3])
        !           425: #define                SIU_PFC_NONE                    0x00
        !           426: #define                SIU_PFC_CIU_FIELDS_INVALID      0x02
        !           427: #define                SIU_PFC_TMF_NOT_SUPPORTED       0x04
        !           428: #define                SIU_PFC_TMF_FAILED              0x05
        !           429: #define                SIU_PFC_INVALID_TYPE_CODE       0x06
        !           430: #define                SIU_PFC_ILLEGAL_REQUEST         0x07
        !           431:
        !           432: #define SIU_SENSE_LENGTH(siu)  (_4btol((siu)->sense_length))
        !           433: #define SIU_SENSE_DATA(siu)    (((siu)->flags & SIU_RSPVALID) ?        \
        !           434:    &(siu)->data[_4btol((siu)->pkt_failures_length)] : &(siu)->data[0])
        !           435:
        !           436: /*
        !           437:  * Values for 'Task Management Flags' field of SPI command information unit.
        !           438:  * See section 14.3.1 of SPI-3.
        !           439:  */
        !           440: #define        SIU_TASKMGMT_NONE               0x00
        !           441: #define        SIU_TASKMGMT_ABORT_TASK         0x01
        !           442: #define        SIU_TASKMGMT_ABORT_TASK_SET     0x02
        !           443: #define        SIU_TASKMGMT_CLEAR_TASK_SET     0x04
        !           444: #define        SIU_TASKMGMT_LUN_RESET          0x08
        !           445: #define        SIU_TASKMGMT_TARGET_RESET       0x20
        !           446: #define        SIU_TASKMGMT_CLEAR_ACA          0x40
        !           447:
        !           448: /*
        !           449:  * Status Byte
        !           450:  */
        !           451: #define SCSI_OK                        0x00
        !           452: #define SCSI_CHECK             0x02
        !           453: #define SCSI_COND_MET          0x04
        !           454: #define SCSI_BUSY              0x08
        !           455: #define SCSI_INTERM            0x10
        !           456: #define SCSI_INTERM_COND_MET   0x14
        !           457: #define SCSI_RESV_CONFLICT     0x18
        !           458: #define SCSI_TERMINATED                0x22
        !           459: #define SCSI_QUEUE_FULL                0x28    /* Old (Pre SCSI-3) name */
        !           460: #define SCSI_TASKSET_FULL      0x28    /* New (SCSI-3)     name */
        !           461: #define SCSI_ACA_ACTIVE                0x30
        !           462:
        !           463: #endif /* _SCSI_SCSI_ALL_H */

CVSweb