[HEADERS]
[reactos.git] / reactos / include / ddk / minitape.h
1 /*
2 * minitape.h
3 *
4 * Minitape driver interface
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22 #ifndef __MINITAPE_H
23 #define __MINITAPE_H
24
25 /* Helper macro to enable gcc's extension. */
26 #ifndef __GNU_EXTENSION
27 #ifdef __GNUC__
28 #define __GNU_EXTENSION __extension__
29 #else
30 #define __GNU_EXTENSION
31 #endif
32 #endif
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #pragma pack(push,4)
39
40 #define MEDIA_ERASEABLE 0x00000001
41 #define MEDIA_WRITE_ONCE 0x00000002
42 #define MEDIA_READ_ONLY 0x00000004
43 #define MEDIA_READ_WRITE 0x00000008
44 #define MEDIA_WRITE_PROTECTED 0x00000100
45 #define MEDIA_CURRENTLY_MOUNTED 0x80000000
46
47 typedef enum _TAPE_STATUS {
48 TAPE_STATUS_SEND_SRB_AND_CALLBACK,
49 TAPE_STATUS_CALLBACK,
50 TAPE_STATUS_CHECK_TEST_UNIT_READY,
51 TAPE_STATUS_SUCCESS,
52 TAPE_STATUS_INSUFFICIENT_RESOURCES,
53 TAPE_STATUS_NOT_IMPLEMENTED,
54 TAPE_STATUS_INVALID_DEVICE_REQUEST,
55 TAPE_STATUS_INVALID_PARAMETER,
56 TAPE_STATUS_MEDIA_CHANGED,
57 TAPE_STATUS_BUS_RESET,
58 TAPE_STATUS_SETMARK_DETECTED,
59 TAPE_STATUS_FILEMARK_DETECTED,
60 TAPE_STATUS_BEGINNING_OF_MEDIA,
61 TAPE_STATUS_END_OF_MEDIA,
62 TAPE_STATUS_BUFFER_OVERFLOW,
63 TAPE_STATUS_NO_DATA_DETECTED,
64 TAPE_STATUS_EOM_OVERFLOW,
65 TAPE_STATUS_NO_MEDIA,
66 TAPE_STATUS_IO_DEVICE_ERROR,
67 TAPE_STATUS_UNRECOGNIZED_MEDIA,
68 TAPE_STATUS_DEVICE_NOT_READY,
69 TAPE_STATUS_MEDIA_WRITE_PROTECTED,
70 TAPE_STATUS_DEVICE_DATA_ERROR,
71 TAPE_STATUS_NO_SUCH_DEVICE,
72 TAPE_STATUS_INVALID_BLOCK_LENGTH,
73 TAPE_STATUS_IO_TIMEOUT,
74 TAPE_STATUS_DEVICE_NOT_CONNECTED,
75 TAPE_STATUS_DATA_OVERRUN,
76 TAPE_STATUS_DEVICE_BUSY,
77 TAPE_STATUS_REQUIRES_CLEANING,
78 TAPE_STATUS_CLEANER_CARTRIDGE_INSTALLED
79 } TAPE_STATUS, *PTAPE_STATUS;
80
81 #define INQUIRYDATABUFFERSIZE 36
82 #ifndef _INQUIRYDATA_DEFINED /* also in scsi.h */
83 #define _INQUIRYDATA_DEFINED
84 typedef struct _INQUIRYDATA {
85 UCHAR DeviceType : 5;
86 UCHAR DeviceTypeQualifier : 3;
87 UCHAR DeviceTypeModifier : 7;
88 UCHAR RemovableMedia : 1;
89 __GNU_EXTENSION union {
90 UCHAR Versions;
91 __GNU_EXTENSION struct {
92 UCHAR ANSIVersion : 3;
93 UCHAR ECMAVersion : 3;
94 UCHAR ISOVersion : 2;
95 };
96 };
97 UCHAR ResponseDataFormat : 4;
98 UCHAR HiSupport : 1;
99 UCHAR NormACA : 1;
100 UCHAR TerminateTask : 1;
101 UCHAR AERC : 1;
102 UCHAR AdditionalLength;
103 UCHAR Reserved;
104 UCHAR Addr16 : 1;
105 UCHAR Addr32 : 1;
106 UCHAR AckReqQ: 1;
107 UCHAR MediumChanger : 1;
108 UCHAR MultiPort : 1;
109 UCHAR ReservedBit2 : 1;
110 UCHAR EnclosureServices : 1;
111 UCHAR ReservedBit3 : 1;
112 UCHAR SoftReset : 1;
113 UCHAR CommandQueue : 1;
114 UCHAR TransferDisable : 1;
115 UCHAR LinkedCommands : 1;
116 UCHAR Synchronous : 1;
117 UCHAR Wide16Bit : 1;
118 UCHAR Wide32Bit : 1;
119 UCHAR RelativeAddressing : 1;
120 UCHAR VendorId[8];
121 UCHAR ProductId[16];
122 UCHAR ProductRevisionLevel[4];
123 UCHAR VendorSpecific[20];
124 UCHAR Reserved3[40];
125 } INQUIRYDATA, *PINQUIRYDATA;
126 #endif
127
128 typedef struct _MODE_CAPABILITIES_PAGE {
129 UCHAR PageCode : 6;
130 UCHAR Reserved1 : 2;
131 UCHAR PageLength;
132 UCHAR Reserved2[2];
133 UCHAR RO : 1;
134 UCHAR Reserved3 : 4;
135 UCHAR SPREV : 1;
136 UCHAR Reserved4 : 2;
137 UCHAR Reserved5 : 3;
138 UCHAR EFMT : 1;
139 UCHAR Reserved6 : 1;
140 UCHAR QFA : 1;
141 UCHAR Reserved7 : 2;
142 UCHAR LOCK : 1;
143 UCHAR LOCKED : 1;
144 UCHAR PREVENT : 1;
145 UCHAR UNLOAD : 1;
146 UCHAR Reserved8 : 2;
147 UCHAR ECC : 1;
148 UCHAR CMPRS : 1;
149 UCHAR Reserved9 : 1;
150 UCHAR BLK512 : 1;
151 UCHAR BLK1024 : 1;
152 UCHAR Reserved10 : 4;
153 UCHAR SLOWB : 1;
154 UCHAR MaximumSpeedSupported[2];
155 UCHAR MaximumStoredDefectedListEntries[2];
156 UCHAR ContinuousTransferLimit[2];
157 UCHAR CurrentSpeedSelected[2];
158 UCHAR BufferSize[2];
159 UCHAR Reserved11[2];
160 } MODE_CAPABILITIES_PAGE, *PMODE_CAPABILITIES_PAGE;
161
162 typedef BOOLEAN DDKAPI
163 (*TAPE_VERIFY_INQUIRY_ROUTINE)(
164 IN PINQUIRYDATA InquiryData,
165 IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage);
166
167 typedef VOID DDKAPI
168 (*TAPE_EXTENSION_INIT_ROUTINE)(
169 IN PVOID MinitapeExtension,
170 IN PINQUIRYDATA InquiryData,
171 IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage);
172
173 typedef VOID DDKAPI
174 (*TAPE_ERROR_ROUTINE)(
175 IN PVOID MinitapeExtension,
176 IN PSCSI_REQUEST_BLOCK Srb,
177 IN OUT PTAPE_STATUS TapeStatus);
178
179 typedef TAPE_STATUS DDKAPI
180 (*TAPE_PROCESS_COMMAND_ROUTINE)(
181 IN OUT PVOID MinitapeExtension,
182 IN OUT PVOID CommandExtension,
183 IN OUT PVOID CommandParameters,
184 IN OUT PSCSI_REQUEST_BLOCK Srb,
185 IN ULONG CallNumber,
186 IN TAPE_STATUS StatusOfLastCommand,
187 IN OUT PULONG RetryFlags);
188
189 #define TAPE_RETRY_MASK 0x0000FFFF
190 #define IGNORE_ERRORS 0x00010000
191 #define RETURN_ERRORS 0x00020000
192
193 typedef struct _TAPE_INIT_DATA {
194 TAPE_VERIFY_INQUIRY_ROUTINE VerifyInquiry;
195 BOOLEAN QueryModeCapabilitiesPage;
196 ULONG MinitapeExtensionSize;
197 TAPE_EXTENSION_INIT_ROUTINE ExtensionInit;
198 ULONG DefaultTimeOutValue;
199 TAPE_ERROR_ROUTINE TapeError;
200 ULONG CommandExtensionSize;
201 TAPE_PROCESS_COMMAND_ROUTINE CreatePartition;
202 TAPE_PROCESS_COMMAND_ROUTINE Erase;
203 TAPE_PROCESS_COMMAND_ROUTINE GetDriveParameters;
204 TAPE_PROCESS_COMMAND_ROUTINE GetMediaParameters;
205 TAPE_PROCESS_COMMAND_ROUTINE GetPosition;
206 TAPE_PROCESS_COMMAND_ROUTINE GetStatus;
207 TAPE_PROCESS_COMMAND_ROUTINE Prepare;
208 TAPE_PROCESS_COMMAND_ROUTINE SetDriveParameters;
209 TAPE_PROCESS_COMMAND_ROUTINE SetMediaParameters;
210 TAPE_PROCESS_COMMAND_ROUTINE SetPosition;
211 TAPE_PROCESS_COMMAND_ROUTINE WriteMarks;
212 TAPE_PROCESS_COMMAND_ROUTINE PreProcessReadWrite; /* optional */
213 } TAPE_INIT_DATA, *PTAPE_INIT_DATA;
214
215 typedef struct _TAPE_PHYS_POSITION {
216 ULONG SeekBlockAddress;
217 ULONG SpaceBlockCount;
218 } TAPE_PHYS_POSITION, PTAPE_PHYS_POSITION;
219
220 #pragma pack(pop)
221
222 #ifdef __cplusplus
223 }
224 #endif
225
226 #endif /* __MINITAPE_H */