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