File: /usr/src/linux/drivers/message/fusion/scsi3.h

1     /*
2      *  linux/drivers/message/fusion/scsi3.h
3      *      SCSI-3 definitions and macros.
4      *      (Ultimately) SCSI-3 definitions; for now, inheriting
5      *      SCSI-2 definitions.
6      *
7      *  Copyright (c) 1996-2001 Steven J. Ralston
8      *  Written By: Steven J. Ralston (19960517)
9      *  (mailto:Steve.Ralston@lsil.com)
10      *
11      *  $Id: scsi3.h,v 1.5 2001/04/06 14:31:32 sralston Exp $
12      */
13     
14     #ifndef SCSI3_H_INCLUDED
15     #define SCSI3_H_INCLUDED
16     /***************************************************************************/
17     
18     /****************************************************************************
19      *
20      *  Includes
21      */
22     #ifdef __KERNEL__
23     #include <linux/types.h>
24     #else
25         #ifndef U_STUFF_DEFINED
26         #define U_STUFF_DEFINED
27         typedef unsigned char u8;
28         typedef unsigned short u16;
29         typedef unsigned int u32;
30         #endif
31     #endif
32     
33     /****************************************************************************
34      *
35      *  Defines
36      */
37     
38     /*
39      *    SCSI Commands
40      */
41     #define CMD_TestUnitReady      0x00
42     #define CMD_RezeroUnit         0x01  /* direct-access devices */
43     #define CMD_Rewind             0x01  /* sequential-access devices */
44     #define CMD_RequestSense       0x03
45     #define CMD_FormatUnit         0x04
46     #define CMD_ReassignBlock      0x07
47     #define CMD_Read6              0x08
48     #define CMD_Write6             0x0A
49     #define CMD_WriteFilemark      0x10
50     #define CMD_Space              0x11
51     #define CMD_Inquiry            0x12
52     #define CMD_ModeSelect6        0x15
53     #define CMD_ModeSense6         0x1A
54     #define CMD_Reserve6           0x16
55     #define CMD_Release6           0x17
56     #define CMD_Erase              0x19
57     #define CMD_StartStopUnit      0x1b  /* direct-access devices */
58     #define CMD_LoadUnload         0x1b  /* sequential-access devices */
59     #define CMD_ReceiveDiagnostic  0x1C
60     #define CMD_SendDiagnostic     0x1D
61     #define CMD_ReadCapacity       0x25
62     #define CMD_Read10             0x28
63     #define CMD_Write10            0x2A
64     #define CMD_WriteVerify        0x2E
65     #define CMD_Verify             0x2F
66     #define CMD_ReadDefectData     0x37
67     #define CMD_ReadLong           0x3E
68     #define CMD_LogSelect          0x4C
69     #define CMD_LogSense           0x4D
70     #define CMD_ModeSelect10       0x55
71     #define CMD_Reserve10          0x56
72     #define CMD_Release10          0x57
73     #define CMD_ModeSense10        0x5A
74     #define CMD_PersistReserveIn   0x5E
75     #define CMD_PersistReserveOut  0x5F
76     #define CMD_ReportLuns         0xA0
77     
78     /*
79      *    Control byte field
80      */
81     #define CONTROL_BYTE_NACA_BIT  0x04
82     #define CONTROL_BYTE_Flag_BIT  0x02
83     #define CONTROL_BYTE_Link_BIT  0x01
84     
85     /*
86      *    SCSI Messages
87      */
88     #define MSG_COMPLETE             0x00
89     #define MSG_EXTENDED             0x01
90     #define MSG_SAVE_POINTERS        0x02
91     #define MSG_RESTORE_POINTERS     0x03
92     #define MSG_DISCONNECT           0x04
93     #define MSG_IDERROR              0x05
94     #define MSG_ABORT                0x06
95     #define MSG_REJECT               0x07
96     #define MSG_NOP                  0x08
97     #define MSG_PARITY_ERROR         0x09
98     #define MSG_LINKED_CMD_COMPLETE  0x0a
99     #define MSG_LCMD_COMPLETE_W_FLG  0x0b
100     #define MSG_BUS_DEVICE_RESET     0x0c
101     #define MSG_ABORT_TAG            0x0d
102     #define MSG_CLEAR_QUEUE          0x0e
103     #define MSG_INITIATE_RECOVERY    0x0f
104     
105     #define MSG_RELEASE_RECOVRY      0x10
106     #define MSG_TERMINATE_IO         0x11
107     
108     #define MSG_SIMPLE_QUEUE         0x20
109     #define MSG_HEAD_OF_QUEUE        0x21
110     #define MSG_ORDERED_QUEUE        0x22
111     #define MSG_IGNORE_WIDE_RESIDUE  0x23
112     
113     #define MSG_IDENTIFY             0x80
114     #define MSG_IDENTIFY_W_DISC      0xc0
115     
116     /*
117      *    SCSI Phases
118      */
119     #define PHS_DATA_OUT  0x00
120     #define PHS_DATA_IN   0x01
121     #define PHS_COMMAND   0x02
122     #define PHS_STATUS    0x03
123     #define PHS_MSG_OUT   0x06
124     #define PHS_MSG_IN    0x07
125     
126     /*
127      *    Statuses
128      */
129     #define STS_GOOD                        0x00
130     #define STS_CHECK_CONDITION             0x02
131     #define STS_CONDITION_MET               0x04
132     #define STS_BUSY                        0x08
133     #define STS_INTERMEDIATE                0x10
134     #define STS_INTERMEDIATE_CONDITION_MET  0x14
135     #define STS_RESERVATION_CONFLICT        0x18
136     #define STS_COMMAND_TERMINATED          0x22
137     #define STS_TASK_SET_FULL               0x28
138     #define    STS_QUEUE_FULL               0x28
139     #define STS_ACA_ACTIVE                  0x30
140     
141     #define STS_VALID_MASK                  0x3e
142     
143     #define SCSI_STATUS(x)  ((x) & STS_VALID_MASK)
144     
145     /*
146      *    SCSI QTag Types
147      */
148     #define QTAG_SIMPLE     0x20
149     #define QTAG_HEAD_OF_Q  0x21
150     #define QTAG_ORDERED    0x22
151     
152     /*
153      *    SCSI Sense Key Definitons
154      */
155     #define SK_NO_SENSE         0x00
156     #define SK_RECOVERED_ERROR  0x01
157     #define SK_NOT_READY        0x02
158     #define SK_MEDIUM_ERROR     0x03
159     #define SK_HARDWARE_ERROR   0x04
160     #define SK_ILLEGAL_REQUEST  0x05
161     #define SK_UNIT_ATTENTION   0x06
162     #define SK_DATA_PROTECT     0x07
163     #define SK_BLANK_CHECK      0x08
164     #define SK_VENDOR_SPECIFIC  0x09
165     #define SK_COPY_ABORTED     0x0a
166     #define SK_ABORTED_COMMAND  0x0b
167     #define SK_EQUAL            0x0c
168     #define SK_VOLUME_OVERFLOW  0x0d
169     #define SK_MISCOMPARE       0x0e
170     #define SK_RESERVED         0x0f
171     
172     
173     
174     #define SCSI_MAX_INQUIRY_BYTES  96
175     #define SCSI_STD_INQUIRY_BYTES  36
176     
177     #undef USE_SCSI_COMPLETE_INQDATA
178     /*
179      *      Structure definition for SCSI Inquiry Data
180      *
181      *  NOTE: The following structure is 96 bytes in size
182      *      iff USE_SCSI_COMPLETE_INQDATA IS defined above (i.e. w/ "#define").
183      *      If USE_SCSI_COMPLETE_INQDATA is NOT defined above (i.e. w/ "#undef")
184      *      then the following structure is only 36 bytes in size.
185      *  THE CHOICE IS YOURS!
186      */
187     typedef struct SCSI_Inquiry_Data
188     {
189     #ifdef USE_SCSI_COMPLETE_INQDATA
190         u8   InqByte[SCSI_MAX_INQUIRY_BYTES];
191     #else
192         u8   InqByte[SCSI_STD_INQUIRY_BYTES];
193     #endif
194     
195     /*
196      * the following structure works only for little-endian (Intel,
197      * LSB first (1234) byte order) systems with 4-byte ints.
198      *
199             u32    Periph_Device_Type    : 5,
200                    Periph_Qualifier      : 3,
201                    Device_Type_Modifier  : 7,
202                    Removable_Media       : 1,
203                    ANSI_Version          : 3,
204                    ECMA_Version          : 3,
205                    ISO_Version           : 2,
206                    Response_Data_Format  : 4,
207                    reserved_0            : 3,
208                    AERC                  : 1  ;
209             u32    Additional_Length     : 8,
210                    reserved_1            :16,
211                    SftReset              : 1,
212                    CmdQue                : 1,
213                    reserved_2            : 1,
214                    Linked                : 1,
215                    Sync                  : 1,
216                    WBus16                : 1,
217                    WBus32                : 1,
218                    RelAdr                : 1  ;
219             u8     Vendor_ID[8];
220             u8     Product_ID[16];
221             u8     Revision_Level [4];
222     #ifdef USE_SCSI_COMPLETE_INQDATA
223             u8     Vendor_Specific[20];
224             u8     reserved_3[40];
225     #endif
226      *
227      */
228     
229     } SCSI_Inquiry_Data_t;
230     
231     #define INQ_PERIPHINFO_BYTE            0
232     #define   INQ_Periph_Qualifier_MASK      0xe0
233     #define   INQ_Periph_Device_Type_MASK    0x1f
234     
235     #define INQ_Peripheral_Qualifier(inqp) \
236         (int)((*((u8*)(inqp)+INQ_PERIPHINFO_BYTE) & INQ_Periph_Qualifier_MASK) >> 5)
237     #define INQ_Peripheral_Device_Type(inqp) \
238         (int)(*((u8*)(inqp)+INQ_PERIPHINFO_BYTE) & INQ_Periph_Device_Type_MASK)
239     
240     
241     #define INQ_DEVTYPEMOD_BYTE            1
242     #define   INQ_RMB_BIT                    0x80
243     #define   INQ_Device_Type_Modifier_MASK  0x7f
244     
245     #define INQ_Removable_Medium(inqp) \
246         (int)(*((u8*)(inqp)+INQ_DEVTYPEMOD_BYTE) & INQ_RMB_BIT)
247     #define INQ_Device_Type_Modifier(inqp) \
248         (int)(*((u8*)(inqp)+INQ_DEVTYPEMOD_BYTE) & INQ_Device_Type_Modifier_MASK)
249     
250     
251     #define INQ_VERSIONINFO_BYTE           2
252     #define   INQ_ISO_Version_MASK           0xc0
253     #define   INQ_ECMA_Version_MASK          0x38
254     #define   INQ_ANSI_Version_MASK          0x07
255     
256     #define INQ_ISO_Version(inqp) \
257         (int)(*((u8*)(inqp)+INQ_VERSIONINFO_BYTE) & INQ_ISO_Version_MASK)
258     #define INQ_ECMA_Version(inqp) \
259         (int)(*((u8*)(inqp)+INQ_VERSIONINFO_BYTE) & INQ_ECMA_Version_MASK)
260     #define INQ_ANSI_Version(inqp) \
261         (int)(*((u8*)(inqp)+INQ_VERSIONINFO_BYTE) & INQ_ANSI_Version_MASK)
262     
263     
264     #define INQ_BYTE3                      3
265     #define   INQ_AERC_BIT                   0x80
266     #define   INQ_TrmTsk_BIT                 0x40
267     #define   INQ_NormACA_BIT                0x20
268     #define   INQ_RDF_MASK                   0x0F
269     
270     #define INQ_AER_Capable(inqp) \
271         (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_AERC_BIT)
272     #define INQ_TrmTsk(inqp) \
273         (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_TrmTsk_BIT)
274     #define INQ_NormACA(inqp) \
275         (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_NormACA_BIT)
276     #define INQ_Response_Data_Format(inqp) \
277         (int)(*((u8*)(inqp)+INQ_BYTE3) & INQ_RDF_MASK)
278     
279     
280     #define INQ_CAPABILITY_BYTE            7
281     #define   INQ_RelAdr_BIT                 0x80
282     #define   INQ_WBus32_BIT                 0x40
283     #define   INQ_WBus16_BIT                 0x20
284     #define   INQ_Sync_BIT                   0x10
285     #define   INQ_Linked_BIT                 0x08
286       /*      INQ_Reserved BIT               0x40 */
287     #define   INQ_CmdQue_BIT                 0x02
288     #define   INQ_SftRe_BIT                  0x01
289     
290     #define IS_RelAdr_DEV(inqp) \
291         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_RelAdr_BIT)
292     #define IS_WBus32_DEV(inqp) \
293         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_WBus32_BIT)
294     #define IS_WBus16_DEV(inqp) \
295         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_WBus16_BIT)
296     #define IS_Sync_DEV(inqp) \
297         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_Sync_BIT)
298     #define IS_Linked_DEV(inqp) \
299         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_Linked_BIT)
300     #define IS_CmdQue_DEV(inqp) \
301         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_CmdQue_BIT)
302     #define IS_SftRe_DEV(inqp) \
303         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_SftRe_BIT)
304     
305     #define INQ_Width_BITS \
306         (INQ_WBus32_BIT | INQ_WBus16_BIT)
307     #define IS_Wide_DEV(inqp) \
308         (int)(*((u8*)(inqp)+INQ_CAPABILITY_BYTE) & INQ_Width_BITS)
309     
310     
311     /*
312      *      SCSI peripheral device types
313      */
314     #define SCSI_TYPE_DAD               0x00  /* Direct Access Device */
315     #define SCSI_TYPE_SAD               0x01  /* Sequential Access Device */
316     #define SCSI_TYPE_TAPE  SCSI_TYPE_SAD
317     #define SCSI_TYPE_PRT               0x02  /* Printer */
318     #define SCSI_TYPE_PROC              0x03  /* Processor */
319     #define SCSI_TYPE_WORM              0x04
320     #define SCSI_TYPE_CDROM             0x05
321     #define SCSI_TYPE_SCAN              0x06  /* Scanner */
322     #define SCSI_TYPE_OPTICAL           0x07  /* Magneto/Optical */
323     #define SCSI_TYPE_CHANGER           0x08
324     #define SCSI_TYPE_COMM              0x09  /* Communications device */
325     #define SCSI_TYPE_UNKNOWN           0x1f
326     #define SCSI_TYPE_UNCONFIGURED_LUN  0x7f
327     
328     #define SCSI_TYPE_MAX_KNOWN         SCSI_TYPE_COMM
329     
330     /*
331      *      Peripheral Qualifiers
332      */
333     #define DEVICE_PRESENT     0x00
334     #define LUN_NOT_PRESENT    0x01
335     #define LUN_NOT_SUPPORTED  0x03
336     
337     /*
338      *      ANSI Versions
339      */
340     #ifndef SCSI_1
341     #define SCSI_1  0x01
342     #endif
343     #ifndef SCSI_2
344     #define SCSI_2  0x02
345     #endif
346     #ifndef SCSI_3
347     #define SCSI_3  0x03
348     #endif
349     
350     
351     #define SCSI_MAX_SENSE_BYTES  255
352     #define SCSI_STD_SENSE_BYTES   18
353     #define SCSI_PAD_SENSE_BYTES      (SCSI_MAX_SENSE_BYTES - SCSI_STD_SENSE_BYTES)
354     
355     #undef USE_SCSI_COMPLETE_SENSE
356     /*
357      *      Structure definition for SCSI Sense Data
358      *
359      *  NOTE: The following structure is 255 bytes in size
360      *      iiff USE_SCSI_COMPLETE_SENSE IS defined above (i.e. w/ "#define").
361      *      If USE_SCSI_COMPLETE_SENSE is NOT defined above (i.e. w/ "#undef")
362      *      then the following structure is only 19 bytes in size.
363      *  THE CHOICE IS YOURS!
364      *
365      */
366     typedef struct SCSI_Sense_Data
367     {
368     #ifdef USE_SCSI_COMPLETE_SENSE
369         u8       SenseByte[SCSI_MAX_SENSE_BYTES];
370     #else
371         u8       SenseByte[SCSI_STD_SENSE_BYTES];
372     #endif
373     
374     /*
375      * the following structure works only for little-endian (Intel,
376      * LSB first (1234) byte order) systems with 4-byte ints.
377      *
378         u8     Error_Code                :4,            // 0x00
379                Error_Class               :3,
380                Valid                     :1
381          ;
382         u8     Segment_Number                           // 0x01
383          ;
384         u8     Sense_Key                 :4,            // 0x02
385                Reserved                  :1,
386                Incorrect_Length_Indicator:1,
387                End_Of_Media              :1,
388                Filemark                  :1
389          ;
390         u8     Information_MSB;                         // 0x03
391         u8     Information_Byte2;                       // 0x04
392         u8     Information_Byte1;                       // 0x05
393         u8     Information_LSB;                         // 0x06
394         u8     Additional_Length;                       // 0x07
395     
396         u32    Command_Specific_Information;            // 0x08 - 0x0b
397     
398         u8     Additional_Sense_Code;                   // 0x0c
399         u8     Additional_Sense_Code_Qualifier;         // 0x0d
400         u8     Field_Replaceable_Unit_Code;             // 0x0e
401         u8     Illegal_Req_Bit_Pointer   :3,            // 0x0f
402                Illegal_Req_Bit_Valid     :1,
403                Illegal_Req_Reserved      :2,
404                Illegal_Req_Cmd_Data      :1,
405                Sense_Key_Specific_Valid  :1
406          ;
407         u16    Sense_Key_Specific_Data;                 // 0x10 - 0x11
408     
409     #ifdef USE_SCSI_COMPLETE_SENSE
410         u8     Additional_Sense_Data[SCSI_PAD_SENSE_BYTES];
411     #else
412         u8     Additional_Sense_Data[1];
413     #endif
414      *
415      */
416     
417     } SCSI_Sense_Data_t;
418     
419     
420     #define SD_ERRCODE_BYTE                0
421     #define   SD_Valid_BIT                   0x80
422     #define   SD_Error_Code_MASK             0x7f
423     #define SD_Valid(sdp) \
424         (int)(*((u8*)(sdp)+SD_ERRCODE_BYTE) & SD_Valid_BIT)
425     #define SD_Error_Code(sdp) \
426         (int)(*((u8*)(sdp)+SD_ERRCODE_BYTE) & SD_Error_Code_MASK)
427     
428     
429     #define SD_SEGNUM_BYTE                 1
430     #define SD_Segment_Number(sdp)  (int)(*((u8*)(sdp)+SD_SEGNUM_BYTE))
431     
432     
433     #define SD_SENSEKEY_BYTE               2
434     #define   SD_Filemark_BIT                0x80
435     #define   SD_EOM_BIT                     0x40
436     #define   SD_ILI_BIT                     0x20
437     #define   SD_Sense_Key_MASK              0x0f
438     #define SD_Filemark(sdp) \
439         (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_Filemark_BIT)
440     #define SD_EOM(sdp) \
441         (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_EOM_BIT)
442     #define SD_ILI(sdp) \
443         (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_ILI_BIT)
444     #define SD_Sense_Key(sdp) \
445         (int)(*((u8*)(sdp)+SD_SENSEKEY_BYTE) & SD_Sense_Key_MASK)
446     
447     
448     #define SD_INFO3_BYTE                  3
449     #define SD_INFO2_BYTE                  4
450     #define SD_INFO1_BYTE                  5
451     #define SD_INFO0_BYTE                  6
452     #define SD_Information3(sdp)  (int)(*((u8*)(sdp)+SD_INFO3_BYTE))
453     #define SD_Information2(sdp)  (int)(*((u8*)(sdp)+SD_INFO2_BYTE))
454     #define SD_Information1(sdp)  (int)(*((u8*)(sdp)+SD_INFO1_BYTE))
455     #define SD_Information0(sdp)  (int)(*((u8*)(sdp)+SD_INFO0_BYTE))
456     
457     
458     #define SD_ADDL_LEN_BYTE               7
459     #define SD_Additional_Sense_Length(sdp) \
460         (int)(*((u8*)(sdp)+SD_ADDL_LEN_BYTE))
461     #define SD_Addl_Sense_Len  SD_Additional_Sense_Length
462     
463     
464     #define SD_CMD_SPECIFIC3_BYTE          8
465     #define SD_CMD_SPECIFIC2_BYTE          9
466     #define SD_CMD_SPECIFIC1_BYTE         10
467     #define SD_CMD_SPECIFIC0_BYTE         11
468     #define SD_Cmd_Specific_Info3(sdp)  (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC3_BYTE))
469     #define SD_Cmd_Specific_Info2(sdp)  (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC2_BYTE))
470     #define SD_Cmd_Specific_Info1(sdp)  (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC1_BYTE))
471     #define SD_Cmd_Specific_Info0(sdp)  (int)(*((u8*)(sdp)+SD_CMD_SPECIFIC0_BYTE))
472     
473     
474     #define SD_ADDL_SENSE_CODE_BYTE       12
475     #define SD_Additional_Sense_Code(sdp) \
476         (int)(*((u8*)(sdp)+SD_ADDL_SENSE_CODE_BYTE))
477     #define SD_Addl_Sense_Code  SD_Additional_Sense_Code
478     #define SD_ASC  SD_Additional_Sense_Code
479     
480     
481     #define SD_ADDL_SENSE_CODE_QUAL_BYTE  13
482     #define SD_Additional_Sense_Code_Qualifier(sdp) \
483         (int)(*((u8*)(sdp)+SD_ADDL_SENSE_CODE_QUAL_BYTE))
484     #define SD_Addl_Sense_Code_Qual  SD_Additional_Sense_Code_Qualifier
485     #define SD_ASCQ  SD_Additional_Sense_Code_Qualifier
486     
487     
488     #define SD_FIELD_REPL_UNIT_CODE_BYTE  14
489     #define SD_Field_Replaceable_Unit_Code(sdp) \
490         (int)(*((u8*)(sdp)+SD_FIELD_REPL_UNIT_CODE_BYTE))
491     #define SD_Field_Repl_Unit_Code  SD_Field_Replaceable_Unit_Code
492     #define SD_FRUC  SD_Field_Replaceable_Unit_Code
493     #define SD_FRU  SD_Field_Replaceable_Unit_Code
494     
495     
496     /*
497      *  Sense-Key Specific offsets and macros.
498      */
499     #define SD_SKS2_BYTE                  15
500     #define   SD_SKS_Valid_BIT               0x80
501     #define   SD_SKS_Cmd_Data_BIT            0x40
502     #define   SD_SKS_Bit_Ptr_Valid_BIT       0x08
503     #define   SD_SKS_Bit_Ptr_MASK            0x07
504     #define SD_SKS1_BYTE                  16
505     #define SD_SKS0_BYTE                  17
506     #define SD_Sense_Key_Specific_Valid(sdp) \
507         (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Valid_BIT)
508     #define SD_SKS_Valid  SD_Sense_Key_Specific_Valid
509     #define SD_SKS_CDB_Error(sdp)  \
510         (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Cmd_Data_BIT)
511     #define SD_Was_Illegal_Request  SD_SKS_CDB_Error
512     #define SD_SKS_Bit_Pointer_Valid(sdp)  \
513         (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Bit_Ptr_Valid_BIT)
514     #define SD_SKS_Bit_Pointer(sdp)  \
515         (int)(*((u8*)(sdp)+SD_SKS2_BYTE) & SD_SKS_Bit_Ptr_MASK)
516     #define SD_Field_Pointer(sdp)  \
517         (int)( ((u16)(*((u8*)(sdp)+SD_SKS1_BYTE)) << 8) \
518           + *((u8*)(sdp)+SD_SKS0_BYTE) )
519     #define SD_Bad_Byte  SD_Field_Pointer
520     #define SD_Actual_Retry_Count  SD_Field_Pointer
521     #define SD_Progress_Indication  SD_Field_Pointer
522     
523     /*
524      *  Mode Sense Write Protect Mask
525      */
526     #define WRITE_PROTECT_MASK      0X80
527     
528     /*
529      *  Medium Type Codes
530      */
531     #define OPTICAL_DEFAULT                 0x00
532     #define OPTICAL_READ_ONLY_MEDIUM        0x01
533     #define OPTICAL_WRITE_ONCE_MEDIUM       0x02
534     #define OPTICAL_READ_WRITABLE_MEDIUM    0x03
535     #define OPTICAL_RO_OR_WO_MEDIUM         0x04
536     #define OPTICAL_RO_OR_RW_MEDIUM         0x05
537     #define OPTICAL_WO_OR_RW_MEDIUM         0x06
538     
539     
540     
541     /*
542      *    Structure definition for READ6, WRITE6 (6-byte CDB)
543      */
544     typedef struct SCSI_RW6_CDB
545     {
546         u32    OpCode      :8,
547                LBA_HI      :5,    /* 5 MSBit's of the LBA */
548                Lun         :3,
549                LBA_MID     :8,    /* NOTE: total of 21 bits in LBA */
550                LBA_LO      :8  ;  /* Max LBA = 0x001fffff          */
551         u8     BlockCount;
552         u8     Control;
553     } SCSI_RW6_t;
554     
555     #define MAX_RW6_LBA  ((u32)0x001fffff)
556     
557     /*
558      *  Structure definition for READ10, WRITE10 (10-byte CDB)
559      *
560      *    NOTE: ParityCheck bit is applicable only for VERIFY and WRITE VERIFY for
561      *    the ADP-92 DAC only.  In the SCSI2 spec. this same bit is defined as a
562      *    FUA (forced unit access) bit for READs and WRITEs.  Since this driver
563      *    does not use the FUA, this bit is defined as it is used by the ADP-92.
564      *    Also, for READ CAPACITY, only the OpCode field is used.
565      */
566     typedef struct SCSI_RW10_CDB
567     {
568         u8     OpCode;
569         u8     Reserved1;
570         u32    LBA;
571         u8     Reserved2;
572         u16    BlockCount;
573         u8     Control;
574     } SCSI_RW10_t;
575     
576     #define PARITY_CHECK  0x08    /* parity check bit - byte[1], bit 3 */
577     
578         /*
579          *  Structure definition for data returned by READ CAPACITY cmd;
580          *  READ CAPACITY data
581          */
582         typedef struct READ_CAP_DATA
583         {
584             u32    MaxLBA;
585             u32    BlockBytes;
586         } SCSI_READ_CAP_DATA_t, *pSCSI_READ_CAP_DATA_t;
587     
588     
589     /*
590      *  Structure definition for FORMAT UNIT CDB (6-byte CDB)
591      */
592     typedef struct _SCSI_FORMAT_UNIT
593     {
594         u8     OpCode;
595         u8     Reserved1;
596         u8     VendorSpecific;
597         u16    Interleave;
598         u8     Control;
599     } SCSI_FORMAT_UNIT_t;
600     
601     /*
602      *    Structure definition for REQUEST SENSE (6-byte CDB)
603      */
604     typedef struct _SCSI_REQUEST_SENSE
605     {
606         u8     OpCode;
607         u8     Reserved1;
608         u8     Reserved2;
609         u8     Reserved3;
610         u8     AllocLength;
611         u8     Control;
612     } SCSI_REQ_SENSE_t;
613     
614     /*
615      *  Structure definition for REPORT LUNS (12-byte CDB)
616      */
617     typedef struct _SCSI_REPORT_LUNS
618     {
619         u8     OpCode;
620         u8     Reserved1[5];
621         u32    AllocationLength;
622         u8     Reserved2;
623         u8     Control;
624     } SCSI_REPORT_LUNS_t, *pSCSI_REPORT_LUNS_t;
625     
626         /*
627          *  (per-level) LUN information bytes
628          */
629     /*
630      *  Following doesn't work on ARMCC compiler
631      *  [apparently] because it pads every struct
632      *  to be multiple of 4 bytes!
633      *  So SCSI_LUN_LEVELS_t winds up being 16
634      *  bytes instead of 8!
635      *
636         typedef struct LUN_INFO
637         {
638             u8     AddrMethod_plus_LunOrBusNumber;
639             u8     LunOrTarget;
640         } SCSI_LUN_INFO_t, *pSCSI_LUN_INFO_t;
641     
642         typedef struct LUN_LEVELS
643         {
644             SCSI_LUN_INFO_t  LUN_0;
645             SCSI_LUN_INFO_t  LUN_1;
646             SCSI_LUN_INFO_t  LUN_2;
647             SCSI_LUN_INFO_t  LUN_3;
648         } SCSI_LUN_LEVELS_t, *pSCSI_LUN_LEVELS_t;
649     */
650         /*
651          *  All 4 levels (8 bytes) of LUN information
652          */
653         typedef struct LUN_LEVELS
654         {
655             u8     LVL1_AddrMethod_plus_LunOrBusNumber;
656             u8     LVL1_LunOrTarget;
657             u8     LVL2_AddrMethod_plus_LunOrBusNumber;
658             u8     LVL2_LunOrTarget;
659             u8     LVL3_AddrMethod_plus_LunOrBusNumber;
660             u8     LVL3_LunOrTarget;
661             u8     LVL4_AddrMethod_plus_LunOrBusNumber;
662             u8     LVL4_LunOrTarget;
663         } SCSI_LUN_LEVELS_t, *pSCSI_LUN_LEVELS_t;
664     
665         /*
666          *  Structure definition for data returned by REPORT LUNS cmd;
667          *  LUN reporting parameter list format
668          */
669         typedef struct LUN_REPORT
670         {
671             u32                LunListLength;
672             u32                Reserved;
673             SCSI_LUN_LEVELS_t  LunInfo[1];
674         } SCSI_LUN_REPORT_t, *pSCSI_LUN_REPORT_t;
675     
676     /****************************************************************************
677      *
678      *  Externals
679      */
680     
681     /****************************************************************************
682      *
683      *  Public Typedefs & Related Defines
684      */
685     
686     /****************************************************************************
687      *
688      *  Macros (embedded, above)
689      */
690     
691     /****************************************************************************
692      *
693      *  Public Variables
694      */
695     
696     /****************************************************************************
697      *
698      *  Public Prototypes (module entry points)
699      */
700     
701     
702     /***************************************************************************/
703     #endif
704