|
|
1.1 root 1: /*++ BUILD Version: 0001 // Increment this if a change has global effects
2:
3: Copyright (c) 1990-1993 Microsoft Corporation
4:
5: Module Name:
6:
7: ntdddisk.h
8:
9: Abstract:
10:
11: This is the include file that defines all constants and types for
12: accessing the Disk device.
13:
14: Author:
15:
16: Steve Wood (stevewo) 27-May-1990
17:
18: Revision History:
19:
20: --*/
21:
22: //
23: // Device Name - this string is the name of the device. It is the name
24: // that should be passed to NtOpenFile when accessing the device.
25: //
26: // Note: For devices that support multiple units, it should be suffixed
27: // with the Ascii representation of the unit number.
28: //
29:
30: #define DD_DISK_DEVICE_NAME "\\Device\\UNKNOWN"
31:
32:
33: //
34: // NtDeviceIoControlFile
35:
36: // begin_winioctl
37:
38: //
39: // IoControlCode values for disk devices.
40: //
41:
42: #define IOCTL_DISK_BASE FILE_DEVICE_DISK
43: #define IOCTL_DISK_GET_DRIVE_GEOMETRY CTL_CODE(IOCTL_DISK_BASE, 0x0000, METHOD_BUFFERED, FILE_ANY_ACCESS)
44: #define IOCTL_DISK_GET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0001, METHOD_BUFFERED, FILE_READ_ACCESS)
45: #define IOCTL_DISK_SET_PARTITION_INFO CTL_CODE(IOCTL_DISK_BASE, 0x0002, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
46: #define IOCTL_DISK_GET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0003, METHOD_BUFFERED, FILE_READ_ACCESS)
47: #define IOCTL_DISK_SET_DRIVE_LAYOUT CTL_CODE(IOCTL_DISK_BASE, 0x0004, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
48: #define IOCTL_DISK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0005, METHOD_BUFFERED, FILE_ANY_ACCESS)
49: #define IOCTL_DISK_FORMAT_TRACKS CTL_CODE(IOCTL_DISK_BASE, 0x0006, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
50: #define IOCTL_DISK_REASSIGN_BLOCKS CTL_CODE(IOCTL_DISK_BASE, 0x0007, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
51: #define IOCTL_DISK_PERFORMANCE CTL_CODE(IOCTL_DISK_BASE, 0x0008, METHOD_BUFFERED, FILE_ANY_ACCESS)
52: #define IOCTL_DISK_IS_WRITABLE CTL_CODE(IOCTL_DISK_BASE, 0x0009, METHOD_BUFFERED, FILE_ANY_ACCESS)
53:
54: // end_winioctl
55: #define IOCTL_DISK_GET_DRIVE_LETTERS CTL_CODE(IOCTL_DISK_BASE, 0x000a, METHOD_BUFFERED, FILE_ANY_ACCESS)
56:
57: // begin_winioctl
58: //
59: // The following device control codes are common for all class drivers. The
60: // functions codes defined here must match all of the other class drivers.
61: //
62:
63: #define IOCTL_DISK_CHECK_VERIFY CTL_CODE(IOCTL_DISK_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
64: #define IOCTL_DISK_MEDIA_REMOVAL CTL_CODE(IOCTL_DISK_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
65: #define IOCTL_DISK_EJECT_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
66: #define IOCTL_DISK_LOAD_MEDIA CTL_CODE(IOCTL_DISK_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
67:
68: // end_winioctl
69: #define IOCTL_DISK_RESERVE CTL_CODE(IOCTL_DISK_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
70: #define IOCTL_DISK_RELEASE CTL_CODE(IOCTL_DISK_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
71:
72: // begin_winioctl
73:
74: #define IOCTL_DISK_GET_MEDIA_TYPES CTL_CODE(IOCTL_DISK_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
75:
76: //
77: // Define the partition types returnable by known disk drivers.
78: //
79:
80: #define PARTITION_ENTRY_UNUSED 0x00 // Entry unused
81: #define PARTITION_FAT_12 0x01 // 12-bit FAT entries
82: #define PARTITION_XENIX_1 0x02 // Xenix
83: #define PARTITION_XENIX_2 0x03 // Xenix
84: #define PARTITION_FAT_16 0x04 // 16-bit FAT entries
85: #define PARTITION_EXTENDED 0x05 // Extended partition entry
86: #define PARTITION_HUGE 0x06 // Huge partition MS-DOS V4
87: #define PARTITION_IFS 0x07 // IFS Partition
88: #define PARTITION_UNIX 0x63 // Unix
89:
90: #define VALID_NTFT 0xC0 // NTFT uses high order bits
91:
92: //
93: // The following macro is used to determine which partitions should be
94: // assigned drive letters.
95: //
96:
97: //++
98: //
99: // BOOLEAN
100: // IsRecognizedPartition(
101: // IN ULONG PartitionType
102: // )
103: //
104: // Routine Description:
105: //
106: // This macro is used to determine to which partitions drive letters
107: // should be assigned.
108: //
109: // Arguments:
110: //
111: // PartitionType - Supplies the type of the partition being examined.
112: //
113: // Return Value:
114: //
115: // The return value is TRUE if the partition type is recognized,
116: // otherwise FALSE is returned.
117: //
118: //--
119:
120: #define IsRecognizedPartition( PartitionType ) ( \
121: (((PartitionType & ~0xC0) == PARTITION_FAT_12) || \
122: ((PartitionType & ~0xC0) == PARTITION_FAT_16) || \
123: ((PartitionType & ~0xC0) == PARTITION_IFS) || \
124: ((PartitionType & ~0xC0) == PARTITION_HUGE)) )
125:
126: //
127: // The high bit of the partition type code indicates that a partition
128: // is part of an NTFT mirror or striped array.
129: //
130:
131: #define PARTITION_NTFT 0x80 // NTFT partition
132:
133: //
134: // Define the media types supported by the driver.
135: //
136:
137: typedef enum _MEDIA_TYPE {
138: Unknown, // Format is unknown
139: F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
140: F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
141: F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
142: F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
143: F3_720_512, // 3.5", 720KB, 512 bytes/sector
144: F5_360_512, // 5.25", 360KB, 512 bytes/sector
145: F5_320_512, // 5.25", 320KB, 512 bytes/sector
146: F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
147: F5_180_512, // 5.25", 180KB, 512 bytes/sector
148: F5_160_512, // 5.25", 160KB, 512 bytes/sector
149: RemovableMedia, // Removable media other than floppy
150: FixedMedia // Fixed hard disk media
151: } MEDIA_TYPE, *PMEDIA_TYPE;
152:
153: //
154: // Define the input buffer structure for the driver, when
155: // it is called with IOCTL_DISK_FORMAT_TRACKS.
156: //
157:
158: typedef struct _FORMAT_PARAMETERS {
159: MEDIA_TYPE MediaType;
160: ULONG StartCylinderNumber;
161: ULONG EndCylinderNumber;
162: ULONG StartHeadNumber;
163: ULONG EndHeadNumber;
164: } FORMAT_PARAMETERS, *PFORMAT_PARAMETERS;
165:
166: //
167: // Define the BAD_TRACK_NUMBER type. An array of elements of this type is
168: // returned by the driver on IOCTL_DISK_FORMAT_TRACKS requests, to indicate
169: // what tracks were bad during formatting. The length of that array is
170: // reported in the `Information' field of the I/O Status Block.
171: //
172:
173: typedef USHORT BAD_TRACK_NUMBER;
174: typedef USHORT *PBAD_TRACK_NUMBER;
175:
176: //
177: // The following structure is returned on an IOCTL_DISK_GET_DRIVE_GEOMETRY
178: // request and an array of them is returned on an IOCTL_DISK_GET_MEDIA_TYPES
179: // request.
180: //
181:
182: typedef struct _DISK_GEOMETRY {
183: LARGE_INTEGER Cylinders;
184: MEDIA_TYPE MediaType;
185: ULONG TracksPerCylinder;
186: ULONG SectorsPerTrack;
187: ULONG BytesPerSector;
188: } DISK_GEOMETRY, *PDISK_GEOMETRY;
189:
190: //
191: // The following structure is returned on an IOCTL_DISK_GET_PARTITION_INFO
192: // and an IOCTL_DISK_GET_DRIVE_LAYOUT request. It is also used in a request
193: // to change the drive layout, IOCTL_DISK_SET_DRIVE_LAYOUT.
194: //
195:
196: typedef struct _PARTITION_INFORMATION {
197: LARGE_INTEGER StartingOffset;
198: LARGE_INTEGER PartitionLength;
199: LARGE_INTEGER HiddenSectors;
200: UCHAR PartitionType;
201: BOOLEAN BootIndicator;
202: BOOLEAN RecognizedPartition;
203: BOOLEAN RewritePartition;
204: } PARTITION_INFORMATION, *PPARTITION_INFORMATION;
205:
206: //
207: // The following structure is used to change the partition type of a
208: // specified disk partition using an IOCTL_DISK_SET_PARTITION_INFO
209: // request.
210: //
211:
212: typedef struct _SET_PARTITION_INFORMATION {
213: UCHAR PartitionType;
214: } SET_PARTITION_INFORMATION, *PSET_PARTITION_INFORMATION;
215:
216: //
217: // The following structures is returned on an IOCTL_DISK_GET_DRIVE_LAYOUT
218: // request and given as input to an IOCTL_DISK_SET_DRIVE_LAYOUT request.
219: //
220:
221: typedef struct _DRIVE_LAYOUT_INFORMATION {
222: ULONG PartitionCount;
223: ULONG Signature;
224: PARTITION_INFORMATION PartitionEntry[1];
225: } DRIVE_LAYOUT_INFORMATION, *PDRIVE_LAYOUT_INFORMATION;
226:
227: //
228: // The following structure is passed in on an IOCTL_DISK_VERIFY request.
229: // The offset and length parameters are both given in bytes.
230: //
231:
232: typedef struct _VERIFY_INFORMATION {
233: LARGE_INTEGER StartingOffset;
234: ULONG Length;
235: } VERIFY_INFORMATION, *PVERIFY_INFORMATION;
236:
237: //
238: // The following structure is passed in on an IOCTL_DISK_REASSIGN_BLOCKS
239: // request.
240: //
241:
242: typedef struct _REASSIGN_BLOCKS {
243: USHORT Reserved;
244: USHORT Count;
245: ULONG BlockNumber[1];
246: } REASSIGN_BLOCKS, *PREASSIGN_BLOCKS;
247:
248: //
249: // The following structure is exchanged on an IOCTL_DISK_GET_PERFORMANCE
250: // request.
251: //
252:
253: typedef struct _DISK_PERFORMANCE {
254: LARGE_INTEGER BytesRead;
255: LARGE_INTEGER BytesWritten;
256: LARGE_INTEGER ReadTime;
257: LARGE_INTEGER WriteTime;
258: ULONG ReadCount;
259: ULONG WriteCount;
260: ULONG QueueDepth;
261: } DISK_PERFORMANCE, *PDISK_PERFORMANCE;
262:
263: //
264: // IOCTL_DISK_MEDIA_REMOVAL disables the mechanism
265: // on a SCSI device that ejects media. This function
266: // may or may not be supported on SCSI devices that
267: // support removable media.
268: //
269: // TRUE means prevent media from being removed.
270: // FALSE means allow media removal.
271: //
272:
273: typedef struct _PREVENT_MEDIA_REMOVAL {
274: BOOLEAN PreventMediaRemoval;
275: } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
276:
277: // end_winioctl
278:
279: //
280: // The following device control code is for the SIMBAD simulated bad
281: // sector facility. See SIMBAD.H in this directory for related structures.
282: //
283:
284: #define IOCTL_DISK_SIMBAD CTL_CODE(IOCTL_DISK_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.