Imported Upstream version 1.1.11
[platform/upstream/cdrkit.git] / libusal / usal / aspi-dos.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 /* @(#)aspi-dos.h       1.2 05/05/15 J. Schilling */
14 #ifndef __ASPI16_H_
15 #define __ASPI16_H_
16
17 #define PACKED  __attribute__((packed))
18 #define FAR
19 typedef unsigned char   BYTE;
20 typedef unsigned short  WORD;
21 typedef unsigned long   DWORD;
22
23 //*****************************************************************************
24 //      %%% SCSI MISCELLANEOUS EQUATES %%%
25 //*****************************************************************************
26
27 #define SENSE_LEN                       14      // Default sense buffer length
28 #define SRB_DIR_SCSI                    0x00    // Direction determined by SCSI
29 #define SRB_POSTING                     0x01    // Enable ASPI posting
30 #define SRB_ENABLE_RESIDUAL_COUNT       0x04    // Enable residual byte count reporting
31 #define SRB_DIR_IN                      0x08    // Transfer from SCSI target to host
32 #define SRB_DIR_OUT                     0x10    // Transfer from host to SCSI target
33
34 //*****************************************************************************
35 //      %%% ASPI Command Definitions %%%
36 //*****************************************************************************
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 information
45
46 //*****************************************************************************
47 //      %%% SRB Status %%%
48 //*****************************************************************************
49
50 #define SS_PENDING                      0x00    // SRB being processed
51 #define SS_COMP                         0x01    // SRB completed without error
52 #define SS_ABORTED                      0x02    // SRB aborted
53 #define SS_ABORT_FAIL                   0x03    // Unable to abort SRB
54 #define SS_ERR                          0x04    // SRB completed with error
55
56 #define SS_INVALID_CMD                  0x80    // Invalid ASPI command
57 #define SS_INVALID_HA                   0x81    // Invalid host adapter number
58 #define SS_NO_DEVICE                    0x82    // SCSI device not installed
59
60 //*****************************************************************************
61 //      %%% Host Adapter Status %%%
62 //*****************************************************************************
63
64 #define HASTAT_OK                       0x00    // Host adapter did not detect an
65                                                 // error
66 #define HASTAT_SEL_TO                   0x11    // Selection Timeout
67 #define HASTAT_DO_DU                    0x12    // Data overrun data underrun
68 #define HASTAT_BUS_FREE                 0x13    // Unexpected bus free
69 #define HASTAT_PHASE_ERR                0x14    // Target bus phase sequence
70                                                 // failure
71 #define HASTAT_TIMEOUT                  0x09    // Timed out while SRB was
72                                                 // waiting to beprocessed.
73 #define HASTAT_COMMAND_TIMEOUT          0x0B    // Adapter timed out processing SRB.
74 #define HASTAT_MESSAGE_REJECT           0x0D    // While processing SRB, the
75                                                 // adapter received a MESSAGE
76 #define HASTAT_BUS_RESET                0x0E    // A bus reset was detected.
77 #define HASTAT_PARITY_ERROR             0x0F    // A parity error was detected.
78 #define HASTAT_REQUEST_SENSE_FAILED     0x10    // The adapter failed in issuing
79
80 typedef struct {
81
82         BYTE    Cmd;                            // 00/000 ASPI command code = SC_EXEC_SCSI_CMD
83         BYTE    Status;                         // 01/001 ASPI command status byte
84         BYTE    HaId;                           // 02/002 ASPI host adapter number
85         BYTE    Flags;                          // 03/003 ASPI request flags
86         DWORD   Hdr_Rsvd;                       // 04/004 Reserved, MUST = 0
87
88         union {
89
90         struct {
91
92                 BYTE    Count;                  // 08/008 Number of host adapters present
93                 BYTE    SCSI_ID;                // 09/009 SCSI ID of host adapter
94                 BYTE    ManagerId[16];          // 0A/010 String describing the manager
95                 BYTE    Identifier[16];         // 1A/026 String describing the host adapter
96                 BYTE    Unique[16];             // 2A/042 Host Adapter Unique parameters
97                 BYTE    ExtBuffer[8];           // 3A/058 Extended inquiry data
98
99         } PACKED HAInquiry;
100
101         struct {
102
103                 BYTE    Target;                 // 08/008 Target's SCSI ID
104                 BYTE    Lun;                    // 09/009 Target's LUN number
105                 BYTE    DeviceType;             // 0A/010 Target's peripheral device type
106
107         } PACKED GetDeviceType;
108
109         struct {
110
111                 BYTE    Target;                 // 08/008 Target's SCSI ID
112                 BYTE    Lun;                    // 09/009 Target's LUN number
113                 DWORD   BufLen;                 // 0A/010 Data Allocation Length
114                 BYTE    SenseLen;               // 0E/014 Sense Allocation Length
115                 BYTE    FAR *BufPointer;        // 0F/015 Data Buffer Pointer
116                 DWORD   Rsvd1;                  // 13/019 Reserved, MUST = 0
117                 BYTE    CDBLen;                 // 17/023 CDB Length = 6/10/12
118                 BYTE    HaStat;                 // 18/024 Host Adapter Status
119                 BYTE    TargStat;               // 19/025 Target Status
120                 VOID    FAR *PostProc;          // 1A/026 Post routine
121                 BYTE    Rsvd2[34];              // 1E/030 Reserved, MUST = 0
122
123                 union {
124
125                 struct {
126
127                         BYTE    CDBByte[6];             // 40/064 SCSI CDB
128                         BYTE    SenseArea[SENSE_LEN+2]; // 46/070 Request Sense buffer
129
130                 } PACKED _6;
131
132                 struct {
133
134                         BYTE    CDBByte[10];            // 40/064 SCSI CDB
135                         BYTE    SenseArea[SENSE_LEN+2]; // 4A/074 Request Sense buffer
136
137                 } PACKED _10;
138
139                 struct {
140
141                         BYTE    CDBByte[12];            // 40/064 SCSI CDB
142                         BYTE    SenseArea[SENSE_LEN+2]; // 4C/076 Request Sense buffer
143
144                 } PACKED _12;
145
146                 } PACKED CmdLen;
147
148         } PACKED ExecSCSICmd;
149
150         struct {
151
152                 VOID    FAR     *SRBToAbort;    // 08/008 Pointer to SRB to abort
153
154         } PACKED Abort;
155
156         struct {
157                 BYTE    Target;         // 08/008 Target's SCSI ID
158                 BYTE    Lun;            // 09/009 Target's LUN number
159                 BYTE    ResetRsvd1[14]; // 0A/010 Reserved, MUST = 0
160                 BYTE    HaStat;         // 18/024 Host Adapter Status
161                 BYTE    TargStat;       // 19/025 Target Status
162                 VOID    FAR *PostProc;  // 1A/026 Post routine
163                 BYTE    ResetRsvd2[34]; // 1E/030 Reserved, MUST = 0
164         } Reset;
165         } PACKED Type;
166
167 } PACKED SRB;
168
169 #endif /* __ASPI16_H_ */