Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / libusal / usal / aspi-win32.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 #ifndef __ASPI_WIN32_H_
14 #define __ASPI_WIN32_H_
15
16 #include <Windows.h>
17
18 /***************************************************************************
19  ** SCSI MISCELLANEOUS EQUATES
20  ***************************************************************************/
21 #define SENSE_LEN                 14     /* Default sense buffer length    */
22 #define SRB_DIR_SCSI              0x00   /* Direction determined by SCSI   */
23 #define SRB_POSTING               0x01   /* Enable ASPI posting            */
24 #define SRB_ENABLE_RESIDUAL_COUNT 0x04   /* Enable residual byte count     */
25                                          /* reporting                      */
26 #define SRB_DIR_IN                0x08   /* Transfer from SCSI target to   */
27                                          /* host                           */
28 #define SRB_DIR_OUT               0x10   /* Transfer from host to SCSI     */
29                                          /* target                         */
30 #define SRB_EVENT_NOTIFY          0x40   /* Enable ASPI event notification */
31 #define RESIDUAL_COUNT_SUPPORTED  0x02   /* Extended buffer flag           */
32 #define MAX_SRB_TIMEOUT       1080001u   /* 30 hour maximum timeout in sec */
33 #define DEFAULT_SRB_TIMEOUT   1080001u   /* use max.timeout by default     */
34
35 /***************************************************************************
36  ** ASPI command definitions
37  ***************************************************************************/
38 #define SC_HA_INQUIRY             0x00   /* Host adapter inquiry           */
39 #define SC_GET_DEV_TYPE           0x01   /* Get device type                */
40 #define SC_EXEC_SCSI_CMD          0x02   /* Execute SCSI command           */
41 #define SC_ABORT_SRB              0x03   /* Abort an SRB                   */
42 #define SC_RESET_DEV              0x04   /* SCSI bus device reset          */
43 #define SC_SET_HA_PARMS           0x05   /* Set HA parameters              */
44 #define SC_GET_DISK_INFO          0x06   /* Get Disk                       */
45 #define SC_RESCAN_SCSI_BUS        0x07   /* Rebuild SCSI device map        */
46 #define SC_GETSET_TIMEOUTS        0x08   /* Get/Set target timeouts        */
47
48
49 /***************************************************************************
50  ** SRB Status
51  ***************************************************************************/
52 #define SS_PENDING                0x00   /* SRB being processed            */
53 #define SS_COMP                   0x01   /* SRB completed without error    */
54 #define SS_ABORTED                0x02   /* SRB aborted                    */
55 #define SS_ABORT_FAIL             0x03   /* Unable to abort SRB            */
56 #define SS_ERR                    0x04   /* SRB completed with error       */
57 #define SS_INVALID_CMD            0x80   /* Invalid ASPI command           */
58 #define SS_INVALID_HA             0x81   /* Invalid host adapter number    */
59 #define SS_NO_DEVICE              0x82   /* SCSI device not installed      */
60 #define SS_INVALID_SRB            0xE0   /* Invalid parameter set in SRB   */
61 #define SS_OLD_MANAGER            0xE1   /* ASPI manager doesn't support   */
62                                          /* windows                        */
63 #define SS_BUFFER_ALIGN           0xE1   /* Buffer not aligned (replaces   */
64                                          /* SS_OLD_MANAGER in Win32)       */
65 #define SS_ILLEGAL_MODE           0xE2   /* Unsupported Windows mode       */
66 #define SS_NO_ASPI                0xE3   /* No ASPI managers               */
67 #define SS_FAILED_INIT            0xE4   /* ASPI for windows failed init   */
68 #define SS_ASPI_IS_BUSY           0xE5   /* No resources available to      */
69                                          /* execute command                */
70 #define SS_BUFFER_TO_BIG          0xE6   /* Buffer size too big to handle  */
71 #define SS_BUFFER_TOO_BIG         0xE6   /* Correct spelling of 'too'      */
72 #define SS_MISMATCHED_COMPONENTS  0xE7   /* The DLLs/EXEs of ASPI don't    */
73                                          /* version check                  */
74 #define SS_NO_ADAPTERS            0xE8   /* No host adapters to manager    */
75 #define SS_INSUFFICIENT_RESOURCES 0xE9   /* Couldn't allocate resources    */
76                                          /* needed to init                 */
77 #define SS_ASPI_IS_SHUTDOWN       0xEA   /* Call came to ASPI after        */
78                                          /* PROCESS_DETACH                 */
79 #define SS_BAD_INSTALL            0xEB   /* The DLL or other components    */
80                                          /* are installed wrong            */
81
82 /***************************************************************************
83  ** Host Adapter Status
84  ***************************************************************************/
85 #define HASTAT_OK                 0x00   /* No error detected by HA        */
86 #define HASTAT_SEL_TO             0x11   /* Selection Timeout              */
87 #define HASTAT_DO_DU              0x12   /* Data overrun/data underrun     */
88 #define HASTAT_BUS_FREE           0x13   /* Unexpected bus free            */
89 #define HASTAT_PHASE_ERR          0x14   /* Target bus phase sequence      */
90 #define HASTAT_TIMEOUT            0x09   /* Timed out while SRB was        */
91                                          /* waiting to be processed        */
92 #define HASTAT_COMMAND_TIMEOUT    0x0B   /* Adapter timed out while        */
93                                          /* processing SRB                 */
94 #define HASTAT_MESSAGE_REJECT     0x0D   /* While processing the SRB, the  */
95                                          /* adapter received a MESSAGE     */
96 #define HASTAT_BUS_RESET          0x0E   /* A bus reset was detected       */
97 #define HASTAT_PARITY_ERROR       0x0F   /* A parity error was detected    */
98 #define HASTAT_REQUEST_SENSE_FAILED 0x10 /* The adapter failed in issuing  */
99
100
101 /***************************************************************************
102  ** SRB - HOST ADAPTER INQUIRIY - SC_HA_INQUIRY (0)
103  ***************************************************************************/
104 typedef struct {
105   BYTE     SRB_Cmd;           /* 00/000 ASPI command code == SC_HA_INQUIRY */
106   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
107   BYTE     SRB_HaId;          /* 02/002 ASPI host adapter number           */
108   BYTE     SRB_Flags;         /* 03/003 ASPI request flags                 */
109   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved, must = 0                 */
110   BYTE     HA_Count;          /* 08/008 Number of host adapters present    */
111   BYTE     HA_SCSI_ID;        /* 09/009 SCSI ID of host adapter            */
112   BYTE     HA_ManagerId[16];  /* 0a/010 String describing the manager      */
113   BYTE     HA_Identifier[16]; /* 1a/026 String describing the host adapter */
114   BYTE     HA_Unique[16];     /* 2a/042 Host Adapter Unique parameters     */
115   WORD     HA_Rsvd1;          /* 3a/058 Reserved, must = 0                 */
116 } PACKED SRB_HAInquiry, *PSRB_HAInquiry, FAR *LPSRB_HAInquiry;
117
118
119 /***************************************************************************
120  ** SRB - GET DEVICE TYPE - SC_GET_DEV_TYPE (1)
121  ***************************************************************************/
122 typedef struct
123 {
124   BYTE     SRB_Cmd;           /* 00/000 ASPI cmd code == SC_GET_DEV_TYPE   */
125   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
126   BYTE     SRB_HaId;          /* 02/002 ASPI host adapter number           */
127   BYTE     SRB_Flags;         /* 03/003 Reserved, must = 0                 */
128   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved, must = 0                 */
129   BYTE     SRB_Target;        /* 08/008 Target's SCSI ID                   */
130   BYTE     SRB_Lun;           /* 09/009 Target's LUN number                */
131   BYTE     SRB_DeviceType;    /* 0a/010 Target's peripheral device type    */
132   BYTE     SRB_Rsvd1;         /* 0b/011 Reserved, must = 0                 */
133 } PACKED SRB_GDEVBlock, *PSRB_GDEVBlock, FAR *LPSRB_GDEVBlock;
134
135
136 /***************************************************************************
137  ** SRB - EXECUTE SCSI COMMAND - SC_EXEC_SCSI_CMD (2)
138  ***************************************************************************/
139 typedef struct
140 {
141   BYTE     SRB_Cmd;           /* 00/000 ASPI cmd code == SC_EXEC_SCSI_CMD  */
142   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
143   BYTE     SRB_HaId;          /* 02/002 ASPI host adapter number           */
144   BYTE     SRB_Flags;         /* 03/003 Reserved, must = 0                 */
145   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved, must = 0                 */
146   BYTE     SRB_Target;        /* 08/008 Target's SCSI ID                   */
147   BYTE     SRB_Lun;           /* 09/009 Target's LUN                       */
148   WORD     SRB_Rsvd1;         /* 0a/010 Reserved for alignment             */
149   DWORD    SRB_BufLen;        /* 0c/012 Data Allocation Length             */
150   BYTE FAR *SRB_BufPointer;   /* 10/016 Data Buffer Pointer                */
151   BYTE     SRB_SenseLen;      /* 14/020 Sense Allocation Length            */
152   BYTE     SRB_CDBLen;        /* 15/021 CDB Length                         */
153   BYTE     SRB_HaStat;        /* 16/022 Host Adapter Status                */
154   BYTE     SRB_TargStat;      /* 17/023 Target Status                      */
155   VOID FAR *SRB_PostProc;     /* 18/024 Post routine                       */
156   BYTE     SRB_Rsvd2[20];     /* 1c/028 Reserved, must = 0                 */
157   BYTE     CDBByte[16];       /* 30/048 SCSI CDB                           */
158   BYTE SenseArea[SENSE_LEN+2]; /* 40/064 Request Sense buffer              */
159 } PACKED SRB_ExecSCSICmd, *PSRB_ExecSCSICmd, FAR *LPSRB_ExecSCSICmd;
160
161
162 typedef struct
163 {
164   BYTE     SRB_Cmd;           /* 00/000 ASPI cmd code == SC_ABORT_SRB      */
165   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
166   BYTE     SRB_HaId;          /* 02/002 ASPI host adapter number           */
167   BYTE     SRB_Flags;         /* 03/003 Reserved, must = 0                 */
168   DWORD    SRB_Hdr_Rsvd;      /* 04/004 Reserved, must = 0                 */
169   void     *SRB_ToAbort;      /* 08/008 Pointer to SRB to abort            */
170 } PACKED SRB_Abort, *PSRB_Abort, FAR *LPSRB_Abort;
171
172
173 /***************************************************************************
174  ** SRB - BUS DEVICE RESET - SC_RESET_DEV (4)
175  ***************************************************************************/
176 typedef struct
177 {
178   BYTE     SRB_Cmd;           /* 00/000 ASPI cmd code == SC_RESET_DEV      */
179   BYTE     SRB_Status;        /* 01/001 ASPI command status byte           */
180   BYTE     SRB_HaId;          /* 02/002 ASPI host adapter number           */
181   DWORD    SRB_Flags;         /* 04/004 Reserved                           */
182   BYTE     SRB_Target;        /* 08/008 Target's SCSI ID                   */
183   BYTE     SRB_Lun;           /* 09/009 Target's LUN number                */
184   BYTE     SRB_Rsvd1[12];     /* 0A/010 Reserved for alignment             */
185   BYTE     SRB_HaStat;        /* 16/022 Host Adapter Status                */
186   BYTE     SRB_TargStat;      /* 17/023 Target Status                      */
187   VOID FAR *SRB_PostProc;     /* 18/024 Post routine                       */
188   BYTE     SRB_Rsvd2[36];     /* 1C/028 Reserved, must = 0                 */
189 } SRB_BusDeviceReset, *PSRB_BusDeviceReset, FAR *LPSRB_BusDeviceReset;
190
191 typedef struct tag_ASPI32BUFF
192 {
193   PBYTE     AB_BufPointer;
194   DWORD     AB_BufLen;
195   DWORD     AB_ZeroFill;
196   DWORD     AB_Reserved;
197 } PACKED ASPI32BUFF, *PASPI32BUFF, FAR *LPASPI32BUFF;
198
199 typedef struct 
200 {
201   BYTE      SRB_Cmd;
202   BYTE      SRB_Status;
203   BYTE      SRB_HaId;
204   BYTE      SRB_Flags;
205   DWORD     SRB_Hdr_Rsvd;
206 } SRB, *PSRB, FAR *LPSRB;
207
208 #endif