Moved interlocked functions to libwine_port.
[wine] / include / ntddstor.h
1 /*
2  * DDK definitions for storage media access
3  *
4  * Copyright (C) 2002 Eric Pouech
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef _NTDDSTOR_H_
22 #define _NTDDSTOR_H_
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 #define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
29
30 #define IOCTL_STORAGE_CHECK_VERIFY      CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
31 #define IOCTL_STORAGE_MEDIA_REMOVAL     CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
32 #define IOCTL_STORAGE_EJECT_MEDIA       CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
33 #define IOCTL_STORAGE_LOAD_MEDIA        CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
34 #define IOCTL_STORAGE_RESERVE           CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
35 #define IOCTL_STORAGE_RELEASE           CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
36 #define IOCTL_STORAGE_FIND_NEW_DEVICES  CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
37 #define IOCTL_STORAGE_GET_MEDIA_TYPES   CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
38 #define IOCTL_STORAGE_GET_MEDIA_TYPES_EX CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
39 #define IOCTL_STORAGE_RESET_BUS         CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
40 #define IOCTL_STORAGE_RESET_DEVICE      CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
41 #define IOCTL_STORAGE_GET_DEVICE_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
42 #define IOCTL_STORAGE_QUERY_PROPERTY    CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
43
44 typedef struct _STORAGE_DEVICE_NUMBER {
45     DEVICE_TYPE         DeviceType;
46     ULONG               DeviceNumber;
47     ULONG               PartitionNumber;
48 } STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
49
50 typedef struct _STORAGE_BUS_RESET_REQUEST {
51     UCHAR               PathId;
52 } STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
53
54 typedef struct _PREVENT_MEDIA_REMOVAL {
55     BOOLEAN             PreventMediaRemoval;
56 } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
57
58 typedef struct _TAPE_STATISTICS {
59     ULONG               Version;
60     ULONG               Flags;
61     LARGE_INTEGER       RecoveredWrites;
62     LARGE_INTEGER       UnrecoveredWrites;
63     LARGE_INTEGER       RecoveredReads;
64     LARGE_INTEGER       UnrecoveredReads;
65     UCHAR               CompressionRatioReads;
66     UCHAR               CompressionRatioWrites;
67 } TAPE_STATISTICS, *PTAPE_STATISTICS;
68
69 #define RECOVERED_WRITES_VALID          0x00000001
70 #define UNRECOVERED_WRITES_VALID        0x00000002
71 #define RECOVERED_READS_VALID           0x00000004
72 #define UNRECOVERED_READS_VALID         0x00000008
73 #define WRITE_COMPRESSION_INFO_VALID    0x00000010
74 #define READ_COMPRESSION_INFO_VALID     0x00000020
75
76 typedef struct _TAPE_GET_STATISTICS {
77     ULONG               Operation;
78 } TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
79
80 #define TAPE_RETURN_STATISTICS          0L
81 #define TAPE_RETURN_ENV_INFO            1L
82 #define TAPE_RESET_STATISTICS           2L
83
84 typedef enum _STORAGE_MEDIA_TYPE {
85     /* see also defines in ntdddisk.h */
86
87     DDS_4mm = 0x20,
88     MiniQic,
89     Travan,
90     QIC,
91     MP_8mm,
92     AME_8mm,
93     AIT1_8mm,
94     DLT,
95     NCTP,
96     IBM_3480,
97     IBM_3490E,
98     IBM_Magstar_3590,
99     IBM_Magstar_MP,
100     STK_DATA_D3,
101     SONY_DTF,
102     DV_6mm,
103     DMI,
104     SONY_D2,
105     CLEANER_CARTRIDGE,
106     CD_ROM,
107     CD_R,
108     CD_RW,
109     DVD_ROM,
110     DVD_R,
111     DVD_RW,
112     MO_3_RW,
113     MO_5_WO,
114     MO_5_RW,
115     MO_5_LIMDOW,
116     PC_5_WO,
117     PC_5_RW,
118     PD_5_RW,
119     ABL_5_WO,
120     PINNACLE_APEX_5_RW,
121     SONY_12_WO,
122     PHILIPS_12_WO,
123     HITACHI_12_WO,
124     CYGNET_12_WO,
125     KODAK_14_WO,
126     MO_NFR_525,
127     NIKON_12_RW,
128     IOMEGA_ZIP,
129     IOMEGA_JAZ,
130     SYQUEST_EZ135,
131     SYQUEST_EZFLYER,
132     SYQUEST_SYJET,
133     AVATAR_F2,
134     MP2_8mm
135 } STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
136
137 #define MEDIA_ERASEABLE         0x00000001
138 #define MEDIA_WRITE_ONCE        0x00000002
139 #define MEDIA_READ_ONLY         0x00000004
140 #define MEDIA_READ_WRITE        0x00000008
141 #define MEDIA_WRITE_PROTECTED   0x00000100
142 #define MEDIA_CURRENTLY_MOUNTED 0x80000000
143
144 typedef struct _DEVICE_MEDIA_INFO {
145     union {
146         struct {
147             LARGE_INTEGER       Cylinders;
148             STORAGE_MEDIA_TYPE  MediaType;
149             ULONG               TracksPerCylinder;
150             ULONG               SectorsPerTrack;
151             ULONG               BytesPerSector;
152             ULONG               NumberMediaSides;
153             ULONG               MediaCharacteristics;
154         } DiskInfo;
155         struct {
156             LARGE_INTEGER       Cylinders;
157             STORAGE_MEDIA_TYPE  MediaType;
158             ULONG               TracksPerCylinder;
159             ULONG               SectorsPerTrack;
160             ULONG               BytesPerSector;
161             ULONG               NumberMediaSides;
162             ULONG               MediaCharacteristics;
163         } RemovableDiskInfo;
164         struct {
165             STORAGE_MEDIA_TYPE  MediaType;
166             ULONG               MediaCharacteristics;
167             ULONG               CurrentBlockSize;
168         } TapeInfo;
169     } DeviceSpecific;
170 } DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
171
172 typedef struct _GET_MEDIA_TYPES {
173     ULONG               DeviceType;
174     ULONG               MediaInfoCount;
175     DEVICE_MEDIA_INFO   MediaInfo[1];
176 } GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
177
178 typedef enum _STORAGE_QUERY_TYPE {
179     PropertyStandardQuery = 0,
180     PropertyExistsQuery,
181     PropertyMaskQuery,
182     PropertyQueryMaxDefined
183 } STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
184
185 typedef enum _STORAGE_PROPERTY_ID {
186     StorageDeviceProperty = 0,
187     StorageAdapterProperty
188 } STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
189
190 typedef struct _STORAGE_PROPERTY_QUERY {
191     STORAGE_PROPERTY_ID         PropertyId;
192     STORAGE_QUERY_TYPE          QueryType;
193     UCHAR                       AdditionalParameters[1];
194 } STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
195
196 typedef struct _STORAGE_DESCRIPTOR_HEADER {
197     ULONG                       Version;
198     ULONG                       Size;
199 } STORAGE_DESCRIPTOR_HEADER, *PSTORAGE_DESCRIPTOR_HEADER;
200
201 typedef enum _STORAGE_BUS_TYPE {
202     BusTypeUnknown = 0x00,
203     BusTypeScsi,
204     BusTypeAtapi,
205     BusTypeAta,
206     BusType1394,
207     BusTypeSsa,
208     BusTypeFibre,
209     BusTypeMaxReserved = 0x7F
210 } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
211
212 typedef struct _STORAGE_DEVICE_DESCRIPTOR {
213     ULONG                       Version;
214     ULONG                       Size;
215     UCHAR                       DeviceType;
216     UCHAR                       DeviceTypeModifier;
217     BOOLEAN                     RemovableMedia;
218     BOOLEAN                     CommandQueueing;
219     ULONG                       VendorIdOffset;
220     ULONG                       ProductIdOffset;
221     ULONG                       ProductRevisionOffset;
222     ULONG                       SerialNumberOffset;
223     STORAGE_BUS_TYPE            BusType;
224     ULONG                       RawPropertiesLength;
225     UCHAR                       RawDeviceProperties[1];
226 } STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
227
228 typedef struct _STORAGE_ADAPTER_DESCRIPTOR {
229     ULONG                       Version;
230     ULONG                       Size;
231     ULONG                       MaximumTransferLength;
232     ULONG                       MaximumPhysicalPages;
233     ULONG                       AlignmentMask;
234     BOOLEAN                     AdapterUsesPio;
235     BOOLEAN                     AdapterScansDown;
236     BOOLEAN                     CommandQueueing;
237     BOOLEAN                     AcceleratedTransfer;
238     BOOLEAN                     BusType;
239     USHORT                      BusMajorVersion;
240     USHORT                      BusMinorVersion;
241 } STORAGE_ADAPTER_DESCRIPTOR, *PSTORAGE_ADAPTER_DESCRIPTOR;
242
243 #ifdef __cplusplus
244 }
245 #endif
246
247 #endif /* _NTDDSTOR_H_ */