1 /*************************************************************************** 2 * * 3 * ASPI Router Library * 4 * * 5 * This is a sample library which shows how to send SRB's to the * 6 * ASPI Router device driver. USE AT YOUR OWN RISK!! * 7 * * 8 * Version 1.01 - June 1997 * 9 * Daniel Dorau (woodst@cs.tu-berlin.de) * 10 * * 11 * Changes since 1.00: * 12 * abort(), AbortSRB added * 13 * * 14 ***************************************************************************/ 15 16 #pragma pack(1) 17 18 /* SRB command */ 19 #define SRB_Inquiry 0x00 20 #define SRB_Device 0x01 21 #define SRB_Command 0x02 22 #define SRB_Abort 0x03 23 #define SRB_Reset 0x04 24 #define SRB_Param 0x05 25 26 /* SRB status */ 27 #define SRB_Busy 0x00 /* SCSI request in progress */ 28 #define SRB_Done 0x01 /* SCSI request completed without error */ 29 #define SRB_Aborted 0x02 /* SCSI aborted by host */ 30 #define SRB_BadAbort 0x03 /* Unable to abort SCSI request */ 31 #define SRB_Error 0x04 /* SCSI request completed with error */ 32 #define SRB_BusyPost 0x10 /* SCSI request in progress with POST - Nokia */ 33 #define SRB_InvalidCmd 0x80 /* Invalid SCSI request */ 34 #define SRB_InvalidHA 0x81 /* Invalid Hhost adapter number */ 35 #define SRB_BadDevice 0x82 /* SCSI device not installed */ 36 37 /* SRB flags */ 38 #define SRB_Post 0x01 /* Post vector valid */ 39 #define SRB_Link 0x02 /* Link vector valid */ 40 #define SRB_SG 0x04 /* Nokia: scatter/gather */ 41 /* S/G: n * (4 bytes length, 4 bytes addr) */ 42 /* No of s/g items not limited by HA spec. */ 43 #define SRB_NoCheck 0x00 /* determined by command, not checked */ 44 #define SRB_Read 0x08 /* target to host, length checked */ 45 #define SRB_Write 0x10 /* host to target, length checked */ 46 #define SRB_NoTransfer 0x18 /* no data transfer */ 47 #define SRB_DirMask 0x18 /* bit mask */ 48 49 /* SRB host adapter status */ 50 #define SRB_NoError 0x00 /* No host adapter detected error */ 51 #define SRB_Timeout 0x11 /* Selection timeout */ 52 #define SRB_DataLength 0x12 /* Data over/underrun */ 53 #define SRB_BusFree 0x13 /* Unexpected bus free */ 54 #define SRB_BusSequence 0x14 /* Target bus sequence failure */ 55 56 /* SRB target status field */ 57 #define SRB_NoStatus 0x00 /* No target status */ 58 #define SRB_CheckStatus 0x02 /* Check status (sense data valid) */ 59 #define SRB_LUN_Busy 0x08 /* Specified LUN is busy */ 60 #define SRB_Reserved 0x18 /* Reservation conflict */ 61 62 #define MaxCDBStatus 64 /* max size of CDB + status */ 63 64 typedef struct SRB SRB; 65 struct SRB { 66 unsigned char cmd, /* 00 */ 67 status, /* 01 */ 68 ha_num, /* 02 */ 69 flags; /* 03 */ 70 unsigned long res_04_07; /* 04..07 */ 71 union { /* 08 */ 72 73 /* SRB_Inquiry */ 74 struct { 75 unsigned char num_ha, /* 08 */ 76 ha_target, /* 09 */ 77 aspimgr_id[16], /* 0A..19 */ 78 host_id[16], /* 1A..29 */ 79 unique_id[16]; /* 2A..39 */ 80 } inq; 81 82 /* SRB_Device */ 83 struct { 84 unsigned char target, /* 08 */ 85 lun, /* 09 */ 86 devtype; /* 0A */ 87 } dev; 88 89 /* SRB_Command */ 90 struct { 91 unsigned char target, /* 08 */ 92 lun; /* 09 */ 93 unsigned long data_len; /* 0A..0D */ 94 unsigned char sense_len; /* 0E */ 95 void * _Seg16 data_ptr; /* 0F..12 */ 96 void * _Seg16 link_ptr; /* 13..16 */ 97 unsigned char cdb_len, /* 17 */ 98 ha_status, /* 18 */ 99 target_status; /* 19 */ 100 void (* _Seg16 post) (SRB *); /* 1A..1D */ 101 unsigned char res_1E_29[12]; /* 1E..29 */ 102 unsigned char res_2A_3F[22]; /* 2A..3F */ 103 unsigned char cdb_st[64]; /* 40..7F CDB+status */ 104 unsigned char res_80_BF[64]; /* 80..BF */ 105 } cmd; 106 107 /* SRB_Abort */ 108 struct { 109 void * _Seg16 srb; /* 08..0B */ 110 } abt; 111 112 /* SRB_Reset */ 113 struct { 114 unsigned char target, /* 08 */ 115 lun, /* 09 */ 116 res_0A_17[14], /* 0A..17 */ 117 ha_status, /* 18 */ 118 target_status; /* 19 */ 119 } res; 120 121 /* SRB_Param - unused by ASPI4OS2 */ 122 struct { 123 unsigned char unique[16]; /* 08..17 */ 124 } par; 125 126 } u; 127 }; 128 129 130 /* SCSI sense codes */ 131 /* Note! This list may not be complete. I did this compilation for use with tape drives.*/ 132 133 #define Sense_Current 0x70; /* Current Error */ 134 #define Sense_Deferred 0x71; /* Deferred Error */ 135 #define Sense_Filemark 0x80; /* Filemark detected */ 136 #define Sense_EOM 0x40; /* End of medium detected */ 137 #define Sense_ILI 0x20; /* Incorrect length indicator */ 138 139 /* Sense Keys */ 140 141 #define SK_NoSense 0x00; /* No Sense */ 142 #define SK_RcvrdErr 0x01; /* Recovered Error */ 143 #define SK_NotReady 0x02; /* Not ready */ 144 #define SK_MedErr 0x03; /* Medium Error */ 145 #define SK_HWErr 0x04; /* Hardware Error */ 146 #define SK_IllReq 0x05; /* Illegal Request */ 147 #define SK_UnitAtt 0x06; /* Unit attention */ 148 #define SK_DataProt 0x07: /* Data Protect */ 149 #define SK_BlankChk 0x08: /* Blank Check */ 150 #define SK_VndSpec 0x09; /* Vendor Specific */ 151 #define SK_CopyAbort 0x0A; /* Copy Aborted */ 152 #define SK_AbtdCmd 0x0B; /* Aborted Command */ 153 #define SK_Equal 0x0C; /* Equal */ 154 #define SK_VolOvfl 0x0D; /* Volume Overflow */ 155 #define SK_MisComp 0x0E; /* Miscompare */ 156 #define SK_Reserved 0x0F; /* Reserved */ 157