1 /* @(#)srb_os2.h	1.0 98/10/28 Copyright 1998 D. Dorau, C. Wohlgemuth */
2 /*
3  *	Definitions for ASPI-Router (ASPIROUT.SYS).
4  *
5  *	Copyright (c) 1998 D. Dorau, C. Wohlgemuth
6  */
7 
8 
9 /*
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2, or (at your option)
13  * any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; see the file COPYING.  If not, write to
22  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24 
25 #pragma pack(1)
26 
27         /* SRB command */
28 #define SRB_Inquiry     0x00
29 #define SRB_Device      0x01
30 #define SRB_Command     0x02
31 #define SRB_Abort       0x03
32 #define SRB_Reset       0x04
33 #define SRB_Param       0x05
34 
35         /* SRB status */
36 #define SRB_Busy        0x00    /* SCSI request in progress */
37 #define SRB_Done        0x01    /* SCSI request completed without error */
38 #define SRB_Aborted     0x02    /* SCSI aborted by host */
39 #define SRB_BadAbort    0x03    /* Unable to abort SCSI request */
40 #define SRB_Error       0x04    /* SCSI request completed with error */
41 #define SRB_BusyPost    0x10    /* SCSI request in progress with POST - Nokia */
42 #define SRB_InvalidCmd  0x80    /* Invalid SCSI request */
43 #define SRB_InvalidHA   0x81    /* Invalid Hhost adapter number */
44 #define SRB_BadDevice   0x82    /* SCSI device not installed */
45 
46         /* SRB flags */
47 #define SRB_Post        0x01    /* Post vector valid */
48 #define SRB_Link        0x02    /* Link vector valid */
49 #define SRB_SG          0x04    /* Nokia: scatter/gather */
50                                 /* S/G: n * (4 bytes length, 4 bytes addr) */
51                                 /* No of s/g items not limited by HA spec. */
52 #define SRB_NoCheck     0x00    /* determined by command, not checked  */
53 #define SRB_Read        0x08    /* target to host, length checked  */
54 #define SRB_Write       0x10    /* host to target, length checked  */
55 #define SRB_NoTransfer  0x18    /* no data transfer  */
56 #define SRB_DirMask     0x18    /* bit mask */
57 
58         /* SRB host adapter status */
59 #define SRB_NoError     0x00    /* No host adapter detected error */
60 #define SRB_Timeout     0x11    /* Selection timeout */
61 #define SRB_DataLength  0x12    /* Data over/underrun */
62 #define SRB_BusFree     0x13    /* Unexpected bus free */
63 #define SRB_BusSequence 0x14    /* Target bus sequence failure */
64 
65         /* SRB target status field */
66 #define SRB_NoStatus    0x00    /* No target status */
67 #define SRB_CheckStatus 0x02    /* Check status (sense data valid) */
68 #define SRB_LUN_Busy    0x08    /* Specified LUN is busy */
69 #define SRB_Reserved    0x18    /* Reservation conflict */
70 
71 #define MaxCDBStatus    64      /* max size of CDB + status */
72 
73 
74 typedef struct SRb {
75         unsigned char   cmd,                            /* 00 */
76                         status,                         /* 01 */
77                         ha_num,                         /* 02 */
78                         flags;                          /* 03 */
79         unsigned long   res_04_07;                      /* 04..07 */
80         union {                                         /* 08 */
81 
82         /* SRB_Inquiry */
83                 struct {
84                         unsigned char   num_ha,         /* 08 */
85                                         ha_target,      /* 09 */
86                                         aspimgr_id[16], /* 0A..19 */
87                                         host_id[16],    /* 1A..29 */
88                                         unique_id[16];  /* 2A..39 */
89                 } inq;
90 
91         /* SRB_Device */
92                 struct {
93                         unsigned char   target,         /* 08 */
94                                         lun,            /* 09 */
95                                         devtype;        /* 0A */
96                 } dev;
97 
98         /* SRB_Command */
99                 struct {
100                         unsigned char   target,         /* 08 */
101                                         lun;            /* 09 */
102                         unsigned long   data_len;       /* 0A..0D */
103                         unsigned char   sense_len;      /* 0E */
104 			unsigned long data_ptr;       /* 0F..12 */
105 			unsigned long link_ptr;       /* 13..16 */
106 		//	void * _Seg16     data_ptr;       /* 0F..12 */
107                   //      void * _Seg16     link_ptr;       /* 13..16 */
108                         unsigned char   cdb_len,        /* 17 */
109                                         ha_status,      /* 18 */
110                                         target_status;  /* 19 */
111 			unsigned char   _Seg16postSRB[4];
112 		//   void    (* _Seg16 post) (SRB *);  /* 1A..1D */
113                         unsigned char   res_1E_29[12];  /* 1E..29 */
114                         unsigned char   res_2A_3F[22];  /* 2A..3F */
115                         unsigned char   cdb_st[64];     /* 40..7F CDB+status */
116                         unsigned char   res_80_BF[64];  /* 80..BF */
117                 } cmd;
118 
119         /* SRB_Abort */
120                 struct {
121 			unsigned char _Seg16srb[4];
122 		//     void * _Seg16     srb;            /* 08..0B */
123                 } abt;
124 
125         /* SRB_Reset */
126                 struct {
127                         unsigned char   target,         /* 08 */
128                                         lun,            /* 09 */
129                                         res_0A_17[14],  /* 0A..17 */
130                                         ha_status,      /* 18 */
131                                         target_status;  /* 19 */
132                 } res;
133 
134         /* SRB_Param - unused by ASPI4OS2 */
135                 struct {
136                         unsigned char   unique[16];     /* 08..17 */
137                 } par;
138 
139         } u;
140 } SRB;
141 
142 
143 // SCSI sense codes
144 // Note! This list may not be complete. I did this compilation for use with tape drives.
145 
146 #define Sense_Current   0x70;   // Current Error
147 #define Sense_Deferred  0x71;   // Deferred Error
148 #define Sense_Filemark  0x80;   // Filemark detected
149 #define Sense_EOM       0x40;   // End of medium detected
150 #define Sense_ILI       0x20;   // Incorrect length indicator
151 
152 // Sense Keys
153 
154 #define SK_NoSense      0x00;   // No Sense
155 #define SK_RcvrdErr     0x01;   // Recovered Error
156 #define SK_NotReady     0x02;   // Not ready
157 #define SK_MedErr       0x03;   // Medium Error
158 #define SK_HWErr        0x04;   // Hardware Error
159 #define SK_IllReq       0x05;   // Illegal Request
160 #define SK_UnitAtt      0x06;   // Unit attention
161 #define SK_DataProt     0x07:   // Data Protect
162 #define SK_BlankChk     0x08:   // Blank Check
163 #define SK_VndSpec      0x09;   // Vendor Specific
164 #define SK_CopyAbort    0x0A;   // Copy Aborted
165 #define SK_AbtdCmd      0x0B;   // Aborted Command
166 #define SK_Equal        0x0C;   // Equal
167 #define SK_VolOvfl      0x0D;   // Volume Overflow
168 #define SK_MisComp      0x0E;   // Miscompare
169 #define SK_Reserved     0x0F;   // Reserved
170