Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / libusal / usal / scsisense.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 /* @(#)scsisense.h      2.18 04/09/04 Copyright 1986 J. Schilling */
14 /*
15  *      Definitions for the SCSI status code and sense structure
16  *
17  *      Copyright (c) 1986 J. Schilling
18  */
19 /*
20  * This program is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License version 2
22  * as published by the Free Software Foundation.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License along with
30  * this program; see the file COPYING.  If not, write to the Free Software
31  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32  */
33
34 #ifndef _SCG_SCSISENSE_H
35 #define _SCG_SCSISENSE_H
36
37 #ifdef  __cplusplus
38 extern "C" {
39 #endif
40
41 /*
42  * SCSI status completion block.
43  */
44 #define SCSI_EXTENDED_STATUS
45
46 #if     defined(_BIT_FIELDS_LTOH)       /* Intel byteorder */
47
48 struct  scsi_status {
49         Ucbit   vu_00   : 1;    /* vendor unique */
50         Ucbit   chk     : 1;    /* check condition: sense data available */
51         Ucbit   cm      : 1;    /* condition met */
52         Ucbit   busy    : 1;    /* device busy or reserved */
53         Ucbit   is      : 1;    /* intermediate status sent */
54         Ucbit   vu_05   : 1;    /* vendor unique */
55 #define st_scsi2        vu_05   /* SCSI-2 modifier bit */
56         Ucbit   vu_06   : 1;    /* vendor unique */
57         Ucbit   st_rsvd : 1;    /* reserved */
58
59 #ifdef  SCSI_EXTENDED_STATUS
60 #define ext_st1 st_rsvd         /* extended status (next byte valid) */
61         /* byte 1 */
62         Ucbit   ha_er   : 1;    /* host adapter detected error */
63         Ucbit   reserved: 6;    /* reserved */
64         Ucbit   ext_st2 : 1;    /* extended status (next byte valid) */
65         /* byte 2 */
66         Uchar   byte2;          /* third byte */
67 #endif  /* SCSI_EXTENDED_STATUS */
68 };
69
70 #else   /* Motorola byteorder */
71
72 struct  scsi_status {
73         Ucbit   st_rsvd : 1;    /* reserved */
74         Ucbit   vu_06   : 1;    /* vendor unique */
75         Ucbit   vu_05   : 1;    /* vendor unique */
76 #define st_scsi2        vu_05   /* SCSI-2 modifier bit */
77         Ucbit   is      : 1;    /* intermediate status sent */
78         Ucbit   busy    : 1;    /* device busy or reserved */
79         Ucbit   cm      : 1;    /* condition met */
80         Ucbit   chk     : 1;    /* check condition: sense data available */
81         Ucbit   vu_00   : 1;    /* vendor unique */
82 #ifdef  SCSI_EXTENDED_STATUS
83 #define ext_st1 st_rsvd         /* extended status (next byte valid) */
84         /* byte 1 */
85         Ucbit   ext_st2 : 1;    /* extended status (next byte valid) */
86         Ucbit   reserved: 6;    /* reserved */
87         Ucbit   ha_er   : 1;    /* host adapter detected error */
88         /* byte 2 */
89         Uchar   byte2;          /* third byte */
90 #endif  /* SCSI_EXTENDED_STATUS */
91 };
92 #endif
93
94 /*
95  * OLD Standard (Non Extended) SCSI Sense. Used mainly by the
96  * Adaptec ACB 4000 which is the only controller that
97  * does not support the Extended sense format.
98  */
99 #if     defined(_BIT_FIELDS_LTOH)       /* Intel byteorder */
100
101 struct  scsi_sense {            /* scsi sense for error classes 0-6 */
102         Ucbit   code    : 7;    /* error class/code */
103         Ucbit   adr_val : 1;    /* sense data is valid */
104 #ifdef  comment
105         Ucbit   high_addr:5;    /* high byte of block addr */
106         Ucbit   rsvd    : 3;
107 #else
108         Uchar   high_addr;      /* high byte of block addr */
109 #endif
110         Uchar   mid_addr;       /* middle byte of block addr */
111         Uchar   low_addr;       /* low byte of block addr */
112 };
113
114 #else   /* Motorola byteorder */
115
116 struct  scsi_sense {            /* scsi sense for error classes 0-6 */
117         Ucbit   adr_val : 1;    /* sense data is valid */
118         Ucbit   code    : 7;    /* error class/code */
119 #ifdef  comment
120         Ucbit   rsvd    : 3;
121         Ucbit   high_addr:5;    /* high byte of block addr */
122 #else
123         Uchar   high_addr;      /* high byte of block addr */
124 #endif
125         Uchar   mid_addr;       /* middle byte of block addr */
126         Uchar   low_addr;       /* low byte of block addr */
127 };
128 #endif
129
130 /*
131  * SCSI extended sense parameter block.
132  */
133 #ifdef  comment
134 #define SC_CLASS_EXTENDED_SENSE 0x7     /* indicates extended sense */
135 #endif
136
137 #if     defined(_BIT_FIELDS_LTOH)       /* Intel byteorder */
138
139 struct  scsi_ext_sense {        /* scsi extended sense for error class 7 */
140         /* byte 0 */
141         Ucbit   type    : 7;    /* fixed at 0x70 */
142         Ucbit   adr_val : 1;    /* sense data is valid */
143         /* byte 1 */
144         Uchar   seg_num;        /* segment number, applies to copy cmd only */
145         /* byte 2 */
146         Ucbit   key     : 4;    /* sense key, see below */
147         Ucbit           : 1;    /* reserved */
148         Ucbit   ili     : 1;    /* incorrect length indicator */
149         Ucbit   eom     : 1;    /* end of media */
150         Ucbit   fil_mk  : 1;    /* file mark on device */
151         /* bytes 3 through 7 */
152         Uchar   info_1;         /* information byte 1 */
153         Uchar   info_2;         /* information byte 2 */
154         Uchar   info_3;         /* information byte 3 */
155         Uchar   info_4;         /* information byte 4 */
156         Uchar   add_len;        /* number of additional bytes */
157         /* bytes 8 through 13, CCS additions */
158         Uchar   optional_8;     /* CCS search and copy only */
159         Uchar   optional_9;     /* CCS search and copy only */
160         Uchar   optional_10;    /* CCS search and copy only */
161         Uchar   optional_11;    /* CCS search and copy only */
162         Uchar   sense_code;     /* sense code */
163         Uchar   qual_code;      /* sense code qualifier */
164         Uchar   fru_code;       /* Field replacable unit code */
165         Ucbit   bptr    : 3;    /* bit pointer for failure (if bpv) */
166         Ucbit   bpv     : 1;    /* bit pointer is valid */
167         Ucbit           : 2;
168         Ucbit   cd      : 1;    /* pointers refer to command not data */
169         Ucbit   sksv    : 1;    /* sense key specific valid */
170         Uchar   field_ptr[2];   /* field pointer for failure */
171         Uchar   add_info[2];    /* round up to 20 bytes */
172 };
173
174 #else   /* Motorola byteorder */
175
176 struct  scsi_ext_sense {        /* scsi extended sense for error class 7 */
177         /* byte 0 */
178         Ucbit   adr_val : 1;    /* sense data is valid */
179         Ucbit   type    : 7;    /* fixed at 0x70 */
180         /* byte 1 */
181         Uchar   seg_num;        /* segment number, applies to copy cmd only */
182         /* byte 2 */
183         Ucbit   fil_mk  : 1;    /* file mark on device */
184         Ucbit   eom     : 1;    /* end of media */
185         Ucbit   ili     : 1;    /* incorrect length indicator */
186         Ucbit           : 1;    /* reserved */
187         Ucbit   key     : 4;    /* sense key, see below */
188         /* bytes 3 through 7 */
189         Uchar   info_1;         /* information byte 1 */
190         Uchar   info_2;         /* information byte 2 */
191         Uchar   info_3;         /* information byte 3 */
192         Uchar   info_4;         /* information byte 4 */
193         Uchar   add_len;        /* number of additional bytes */
194         /* bytes 8 through 13, CCS additions */
195         Uchar   optional_8;     /* CCS search and copy only */
196         Uchar   optional_9;     /* CCS search and copy only */
197         Uchar   optional_10;    /* CCS search and copy only */
198         Uchar   optional_11;    /* CCS search and copy only */
199         Uchar   sense_code;     /* sense code */
200         Uchar   qual_code;      /* sense code qualifier */
201         Uchar   fru_code;       /* Field replacable unit code */
202         Ucbit   sksv    : 1;    /* sense key specific valid */
203         Ucbit   cd      : 1;    /* pointers refer to command not data */
204         Ucbit           : 2;
205         Ucbit   bpv     : 1;    /* bit pointer is valid */
206         Ucbit   bptr    : 3;    /* bit pointer for failure (if bpv) */
207         Uchar   field_ptr[2];   /* field pointer for failure */
208         Uchar   add_info[2];    /* round up to 20 bytes */
209 };
210 #endif
211
212 #ifdef  __cplusplus
213 }
214 #endif
215
216 #endif  /* _SCG_SCSISENSE_H */