⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scsi-defs.h

📁 开源备份软件源码 AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that a
💻 H
📖 第 1 页 / 共 3 页
字号:
/* * Copyright (c) 1998 T.Hepper */#ifndef SCSIDEFS_H#define SCSIDEFS_H#ifndef WORDS_BIGENDIAN#define LITTLE_ENDIAN_BITFIELDS#endiftypedef enum { Input, Output } Direction_T; typedef unsigned char CDB_T[12];#ifdef _AIXtypedef unsigned int PackedBit;#define AIX_USE_GSC 1#elsetypedef unsigned char PackedBit;#endif#define INDEX_CHANGER 0#define INDEX_TAPE 1#define INDEX_TAPECTL 2#define CHG_MAXDEV 32		/* Maximum number of devices handled by pDev */				/* Must be large to hold the result of ScanBus */#define TAPETYPE 4#define IMPORT 3#define STORAGE 2#define CHANGER 1#define TAG_SIZE 36#define MAXTRIES 100  /* How many tries until SCSI_TestUnitReady should return an ok *//* * Sense Key definitions*/#define SENSE_NULL 0#define SENSE_RECOVERED_ERROR 1#define NOT_READY 2#define SENSE_NOT_READY 2#define SENSE_MEDIUM_ERROR 3#define SENSE_HARDWARE_ERROR 4#define HARDWARE_ERROR 4#define ILLEGAL_REQUEST 5#define SENSE_ILLEGAL_REQUEST 5#define UNIT_ATTENTION 6#define SENSE_UNIT_ATTENTION 6#define SENSE_DATA_PROTECT 7#define SENSE_BLANK_CHECK 8#define SENSE_VENDOR_SPECIFIC 0x9#define SENSE_ABORTED_COMMAND 0xb#define SENSE_VOLUME_OVERFLOW 0xd#define SENSE_CHG_ELEMENT_STATUS 0xe#define MAX_RETRIES 100#define INQUIRY_SIZE SIZEOF(SCSIInquiry_T)/* * Return values from the OS dependent part * of the SCSI interface * * The underlaying functions must decide what to do */#define SCSI_ERROR -1#define SCSI_OK 0#define SCSI_SENSE 1#define SCSI_BUSY 2#define SCSI_CHECK 3/* *  SCSI Commands*/#define SC_COM_TEST_UNIT_READY 0#define SC_COM_REWIND 0x1#define SC_COM_REQUEST_SENSE 0x3#define SC_COM_IES 0x7#define SC_COM_INQUIRY 0x12#define SC_COM_MODE_SELECT 0x15#define SC_COM_ERASE 0x19#define SC_COM_MODE_SENSE 0x1A#define SC_COM_UNLOAD 0x1B#define SC_COM_LOCATE 0x2B#define SC_COM_LOG_SELECT 0x4C#define SC_COM_LOG_SENSE 0x4d#define SC_MOVE_MEDIUM 0xa5#define SC_COM_RES 0xb8/* * Define for LookupDevice */#define LOOKUP_NAME 1#define LOOKUP_FD 2#define LOOKUP_TYPE 3#define LOOKUP_CONFIG 4/*  * Define for the return codes from SenseHandler */#define SENSE_ABORT -1#define SENSE_IGNORE 0#define SENSE_RETRY 2#define SENSE_IES 3#define SENSE_TAPE_NOT_ONLINE 4#define SENSE_TAPE_NOT_LOADED 5#define SENSE_NO 6#define SENSE_TAPE_NOT_UNLOADED 7#define SENSE_CHM_FULL 8/* * Defines for the type field in the inquiry command */#define TYPE_DISK 0#define TYPE_TAPE 1#define TYPE_PRINTER 2#define TYPE_PROCESSOR 3#define TYPE_WORM 4#define TYPE_CDROM 5#define TYPE_SCANNER 6#define TYPE_OPTICAL 7#define TYPE_CHANGER 8#define TYPE_COMM 9/* Defines for Tape_Status */#define TAPE_ONLINE 1        /* Tape is loaded */#define TAPE_BOT 2           /* Tape is at begin of tape */#define TAPE_EOT 4           /* Tape is at end of tape */#define TAPE_WR_PROT 8       /* Tape is write protected */#define TAPE_NOT_LOADED 16   /* Tape is not loaded *//* Defines for the function Tape_Ioctl */#define IOCTL_EJECT 0/* Defines for exit status */#define WARNING 1#define FATAL	2/* macros for building scsi msb array parameter lists */#ifndef B#define B(s,i) ((unsigned char)(((s) >> (i)) & 0xff))#endif#ifndef B1#define B1(s)  ((unsigned char)((s) & 0xff))#endif#define B2(s)                       B((s),8),   B1(s)#define B3(s)            B((s),16), B((s),8),   B1(s)#define B4(s) B((s),24), B((s),16), B((s),8),   B1(s)/* macros for converting scsi msb array to binary */#define V1(s)           (s)[0]#define V2(s)         (((s)[0] << 8) | (s)[1])#define V3(s)       (((((s)[0] << 8) | (s)[1]) << 8) | (s)[2])#define V4(s)     (((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3])#define V5(s)   (((((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3]) << 8) | (s)[4])#define V6(s) (((((((((((s)[0] << 8) | (s)[1]) << 8) | (s)[2]) << 8) | (s)[3]) << 8) | (s)[4]) << 8) | (s)[5])/* macros for converting binary into scsi msb array */#define MSB1(s,v)                                                (s)[0]=B1(v)#define MSB2(s,v)                                 (s)[0]=B(v,8), (s)[1]=B1(v)#define MSB3(s,v)                 (s)[0]=B(v,16), (s)[1]=B(v,8), (s)[2]=B1(v)#define MSB4(s,v) (s)[0]=B(v,24), (s)[1]=B(v,16), (s)[2]=B(v,8), (s)[3]=B1(v)#define LABEL_DB_VERSION 2#define DEBUG_INFO 9#define DEBUG_ERROR 1#define DEBUG_ALL 0#define SECTION_ALL 0#define SECTION_INFO 1#define SECTION_SCSI 2#define SECTION_MAP_BARCODE 3#define SECTION_ELEMENT 4#define SECTION_BARCODE 5#define SECTION_TAPE 6#define SECTION_MOVE 7/*----------------------------------------------------------------------------*//* Some stuff for our own configurationfile */typedef struct {  /* The information we can get for any drive (configuration) */  int	drivenum;    /* Which drive to use in the library */  int	start;       /* Which is the first slot we may use */  int	end;         /* The last slot we are allowed to use */  int	cleanslot;   /* Where the cleaningcartridge stays */  char *scsitapedev; /* Where can we send raw SCSI commands to the tape */  char *device;      /* Which device is associated to the drivenum */  char *slotfile;    /* Where we should have our memory */     char *cleanfile;   /* Where we count how many cleanings we did */  char *timefile;    /* Where we count the time the tape was used*/  char *tapestatfile;/* Where can we place some drive stats */  char *changerident;/* Config to use for changer control, ovverride result from inquiry */  char *tapeident;   /* Same as above for the tape device */}config_t; typedef struct {  int number_of_configs; /* How many different configurations are used */  int eject;             /* Do the drives need an eject-command */  int autoinv;           /* Do automaticly an inventory if an tape is not in the db or not active in the db */  int havebarcode;       /* Do we have an barcode reader installed */  char *debuglevel;      /* How many debug info to print */  unsigned char emubarcode;	/* Emulate the barcode feature,  used for keeping an inventory of the lib */  time_t sleep;          /* How many seconds to wait for the drive to get ready */  int cleanmax;          /* How many runs could be done with one cleaning tape */  char *device;          /* Which device is our changer */  char *labelfile;       /* Mapping from Barcode labels to volume labels */  config_t *conf;}changer_t;typedef struct {  char voltag[128];  char barcode[TAG_SIZE];  unsigned char valid;} LabelV1_T;typedef struct {  char voltag[128];              /* Tape volume label */  char barcode[TAG_SIZE];        /* Barcode of the tape */  int slot;                      /* in which slot is the tape */  int from;                      /* from where it comes, needed to move a tape				  * back to the right slot from the drive				  */  unsigned int LoadCount;	/* How many times has the tape been loaded */  unsigned int RecovError;	/* How many recovered errors */  unsigned int UnrecovError;	/* How man unrecoverd errors */  unsigned char valid;		/* Is this tape in the current magazin */} LabelV2_T;typedef enum {BARCODE_PUT, BARCODE_VOL, BARCODE_BARCODE, BARCODE_DUMP, RESET_VALID, FIND_SLOT, UPDATE_SLOT } MBCAction_T;typedef struct {  LabelV2_T data;  MBCAction_T action;} MBC_T;/* ======================================================= *//* RequestSense_T *//* ======================================================= */typedef struct  {#ifdef LITTLE_ENDIAN_BITFIELDS     PackedBit     ErrorCode:7;                    /* Byte 0 Bits 0-6 */    PackedBit     Valid:1;                              /* Byte 0 Bit 7    */#else     PackedBit     Valid:1;                              /* Byte 0 Bit 7    */    PackedBit     ErrorCode:7;                    /* Byte 0 Bits 0-6 */#endif    unsigned char SegmentNumber;                  /* Byte 1 */ #ifdef LITTLE_ENDIAN_BITFIELDS            PackedBit     SenseKey:4;                     /* Byte 2 Bits 0-3 */    PackedBit     :1;                             /* Byte 2 Bit 4    */    PackedBit     RILI:1;                                /* Byte 2 Bit 5    */    PackedBit     REOM:1;                                /* Byte 2 Bit 6    */    PackedBit     Filemark:1;                           /* Byte 2 Bit 7    */#else     PackedBit     Filemark:1;                           /* Byte 2 Bit 7    */    PackedBit     REOM:1;                                /* Byte 2 Bit 6    */    PackedBit     RILI:1;                                /* Byte 2 Bit 5    */    PackedBit     :1;                             /* Byte 2 Bit 4    */     PackedBit     SenseKey:4;                     /* Byte 2 Bits 0-3 */#endif    unsigned char Information[4];                 /* Bytes 3-6       */     unsigned char AdditionalSenseLength;          /* Byte 7          */       unsigned char CommandSpecificInformation[4];  /* Bytes 8-11      */     unsigned char AdditionalSenseCode;            /* Byte 12         */    unsigned char AdditionalSenseCodeQualifier;   /* Byte 13         */     unsigned char Byte14;                          /* Byte 14         */     unsigned char Byte15;                           /* Byte 15         */     } RequestSense_T;     /* ======================================================= *//* ExtendedRequestSense_T *//* ======================================================= */typedef struct  {#ifdef LITTLE_ENDIAN_BITFIELDS     PackedBit     ErrorCode:7;                    /* Byte 0 Bits 0-6 */    PackedBit     Valid:1;                        /* Byte 0 Bit 7    */#else     PackedBit     Valid:1;                        /* Byte 0 Bit 7    */    PackedBit     ErrorCode:7;                    /* Byte 0 Bits 0-6 */#endif    unsigned char SegmentNumber;                  /* Byte 1 */ #ifdef LITTLE_ENDIAN_BITFIELDS            PackedBit     SenseKey:4;                     /* Byte 2 Bits 0-3 */    PackedBit     :1;                             /* Byte 2 Bit 4    */    PackedBit     RILI:1;                         /* Byte 2 Bit 5    */    PackedBit     REOM:1;                         /* Byte 2 Bit 6    */    PackedBit     Filemark:1;                     /* Byte 2 Bit 7    */#else     PackedBit     Filemark:1;                     /* Byte 2 Bit 7    */    PackedBit     REOM:1;                         /* Byte 2 Bit 6    */    PackedBit     RILI:1;                         /* Byte 2 Bit 5    */    PackedBit     :1;                             /* Byte 2 Bit 4    */     PackedBit     SenseKey:4;                     /* Byte 2 Bits 0-3 */#endif    unsigned char Information[4];                 /* Bytes 3-6       */     unsigned char AdditionalSenseLength;          /* Byte 7          */       unsigned char LogParameterPageCode;           /* Bytes 8         */     unsigned char LogParameterCode;               /* Bytes 9         */     unsigned char Byte10;                         /* Bytes 10        */     unsigned char UnderrunOverrunCounter;         /* Bytes 11        */     unsigned char AdditionalSenseCode;            /* Byte 12         */    unsigned char AdditionalSenseCodeQualifier;   /* Byte 13         */     unsigned char Byte14;                         /* Byte 14         */     unsigned char Byte15;                         /* Byte 15         */     unsigned char ReadWriteDataErrorCounter[3];   /* Byte 16-18      */ #ifdef LITTLE_ENDIAN_BITFIELDS            PackedBit     LBOT:1;                         /* Byte 19 Bits 0 */    PackedBit     TNP:1;                          /* Byte 19 Bits 1 */    PackedBit     TME:1;                          /* Byte 19 Bits 2 */    PackedBit     ECO:1;                          /* Byte 19 Bits 3 */    PackedBit     ME:1;                           /* Byte 19 Bits 4 */    PackedBit     FPE:1;                          /* Byte 19 Bits 5 */    PackedBit     BPE:1;                          /* Byte 19 Bits 6 */    PackedBit     PF:1;                           /* Byte 19 Bits 7 */#else     PackedBit     PF:1;                           /* Byte 19 Bits 7 */    PackedBit     BPE:1;                          /* Byte 19 Bits 6 */    PackedBit     FPE:1;                          /* Byte 19 Bits 5 */    PackedBit     ME:1;                           /* Byte 19 Bits 4 */    PackedBit     ECO:1;                          /* Byte 19 Bits 3 */    PackedBit     TME:1;                          /* Byte 19 Bits 2 */    PackedBit     TNP:1;                          /* Byte 19 Bits 1 */    PackedBit     LBOT:1;                         /* Byte 19 Bits 0 */#endif#ifdef LITTLE_ENDIAN_BITFIELDS            PackedBit     FE:1;                           /* Byte 20 Bits 0 */    PackedBit     SSE:1;                          /* Byte 20 Bits 1 */    PackedBit     WEI:1;                          /* Byte 20 Bits 2 */    PackedBit     URE:1;                          /* Byte 20 Bits 3 */    PackedBit     FMKE:1;                         /* Byte 20 Bits 4 */    PackedBit     WP:1;                           /* Byte 20 Bits 5 */    PackedBit     TMD:1;                          /* Byte 20 Bits 6 */    PackedBit     :1;                             /* Byte 20 Bits 7 */#else     PackedBit     :1;                             /* Byte 20 Bits 7 */    PackedBit     TMD:1;                          /* Byte 20 Bits 6 */    PackedBit     WP:1;                           /* Byte 20 Bits 5 */    PackedBit     FMKE:1;                         /* Byte 20 Bits 4 */    PackedBit     URE:1;                          /* Byte 20 Bits 3 */    PackedBit     WEI:1;                          /* Byte 20 Bits 2 */    PackedBit     SSE:1;                          /* Byte 20 Bits 1 */    PackedBit     FE:1;                           /* Byte 20 Bits 0 */#endif#ifdef LITTLE_ENDIAN_BITFIELDS            PackedBit     WSEO:1;                         /* Byte 21 Bits 0 */    PackedBit     WSEB:1;                         /* Byte 21 Bits 1 */    PackedBit     PEOT:1;                         /* Byte 21 Bits 2 */    PackedBit     CLN:1;                          /* Byte 21 Bits 3 */    PackedBit     CLND:1;                         /* Byte 21 Bits 4 */    PackedBit     RRR:1;                          /* Byte 21 Bits 5 */    PackedBit     UCLN:1;                         /* Byte 21 Bits 6 */    PackedBit     :1;                             /* Byte 21 Bits 7 */#else     PackedBit     :1;                             /* Byte 21 Bits 7 */    PackedBit     UCLN:1;                         /* Byte 21 Bits 6 */    PackedBit     RRR:1;                          /* Byte 21 Bits 5 */    PackedBit     CLND:1;                         /* Byte 21 Bits 4 */    PackedBit     CLN:1;                          /* Byte 21 Bits 3 */    PackedBit     PEOT:1;                         /* Byte 21 Bits 2 */    PackedBit     WSEB:1;                         /* Byte 21 Bits 1 */    PackedBit     WSEO:1;                         /* Byte 21 Bits 0 */#endif    unsigned char Byte21;                          /* Byte 22         */     unsigned char RemainingTape[3];                /* Byte 23-25      */     unsigned char TrackingRetryCounter;            /* Byte 26         */     unsigned char ReadWriteRetryCounter;           /* Byte 27         */     unsigned char FaultSymptomCode;                /* Byte 28         */     } ExtendedRequestSense_T;     /* ======================================================= *//*  ReadElementStatus_T *//* ======================================================= */typedef struct {    unsigned char cmd;                           /* Byte 1 */#ifdef LITTLE_ENDIAN_BITFIELDS            PackedBit     type : 4;    PackedBit     voltag :1;    PackedBit     lun :3;#else    PackedBit     lun :3;    PackedBit     voltag :1;    PackedBit     type : 4;#endif    unsigned char start[2];                    /* Byte 3-4 */    unsigned char number[2];                   /* Byte 5-6 */    unsigned char byte4;                       /* Byte 7 */    unsigned char length[4];                   /* Byte 8-11 */    unsigned char byte78[2];                   /* Byte 12-13 */} ReadElementStatus_T;/* ======================================================= *//* ElementStatusPage_T *//* ======================================================= */typedef struct {    unsigned char type;     /* Byte 1 = Element Type Code*/#ifdef LITTLE_ENDIAN_BITFIELDS            PackedBit     bitres  : 6;    PackedBit     avoltag : 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -