-
Notifications
You must be signed in to change notification settings - Fork 1
/
IOATAStorageDefines.h
321 lines (268 loc) · 9.2 KB
/
IOATAStorageDefines.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
/*
* Copyright (c) 1998-2007 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#ifndef _IOKIT_IO_ATA_STORAGE_DEFINES_H_
#define _IOKIT_IO_ATA_STORAGE_DEFINES_H_
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Important word offsets in device identify data as
* defined in ATA-5 standard
*/
enum
{
kATAIdentifyConfiguration = 0,
kATAIdentifyLogicalCylinderCount = 1,
kATAIdentifyLogicalHeadCount = 3,
kATAIdentifySectorsPerTrack = 6,
kATAIdentifySerialNumber = 10,
kATAIdentifyFirmwareRevision = 23,
kATAIdentifyModelNumber = 27,
kATAIdentifyMultipleSectorCount = 47,
kATAIdentifyDriveCapabilities = 49,
kATAIdentifyDriveCapabilitiesExtended = 50,
kATAIdentifyPIOTiming = 51,
kATAIdentifyExtendedInfoSupport = 53,
kATAIdentifyCurrentCylinders = 54,
kATAIdentifyCurrentHeads = 55,
kATAIdentifyCurrentSectors = 56,
kATAIdentifyCurrentCapacity = 57,
kATAIdentifyCurrentMultipleSectors = 59,
kATAIdentifyLBACapacity = 60,
kATAIdentifySingleWordDMA = 62,
kATAIdentifyMultiWordDMA = 63,
kATAIdentifyAdvancedPIOModes = 64,
kATAIdentifyMinMultiWordDMATime = 65,
kATAIdentifyRecommendedMultiWordDMATime = 66,
kATAIdentifyMinPIOTime = 67,
kATAIdentifyMinPIOTimeWithIORDY = 68,
kATAIdentifyQueueDepth = 75,
kATAIdentifyMajorVersion = 80,
kATAIdentifyMinorVersion = 81,
kATAIdentifyCommandSetSupported = 82,
kATAIdentifyCommandSetSupported2 = 83,
kATAIdentifyCommandExtension1 = 84,
kATAIdentifyCommandExtension2 = 85,
kATAIdentifyCommandsEnabled = 86,
kATAIdentifyCommandsDefault = 87,
kATAIdentifyUltraDMASupported = 88,
kATAIdentifyPhysicalLogicalSectorSize = 106,
kATAIdentifyWordsPerLogicalSector1 = 117,
kATAIdentifyWordsPerLogicalSector2 = 118,
kATAIdentifyLogicalSectorAlignment = 209,
kATAIdentifyIntegrity = 255
};
/*
* Important bits in device identify data
* as defined in ATA-5 standard
*/
enum
{
// Configuration field (word 0)
kFixedDeviceBit = 6, // Fixed disk indicator bit
kRemoveableMediaBit = 7, // Removable media indicator bit
kNonMagneticDriveBit = 15, // Non-magnetic drive indicator bit
kFixedDeviceMask = (1 << kFixedDeviceBit), // Mask for fixed disk indicator
kRemoveableMediaMask = (1 << kRemoveableMediaBit), // Mask for removable media indicator
kNonMagneticDriveMask = (1 << kNonMagneticDriveBit), // Mask for non-magnetic drive indicator
// Capabilities field (word 49)
kDMABit = 8, // DMA supported bit
kLBABit = 9, // LBA supported bit
kIORDYDisableBit = 10, // IORDY can be disabled bit
kIORDYBit = 11, // IORDY supported bit
kStandbyTimerBit = 13, // Standby timer supported bit
kDMASupportedMask = (1 << kDMABit), // Mask for DMA supported
kLBASupportedMask = (1 << kLBABit), // Mask for LBA supported
kDMADisableMask = (1 << kIORDYDisableBit), // Mask for DMA supported
kIORDYSupportedMask = (1 << kIORDYBit), // Mask for IORDY supported
kStandbySupportedMask = (1 << kStandbyTimerBit), // Mask for Standby Timer supported
// Extensions field (word 53)
kCurFieldsValidBit = 0, // Bit to show words 54-58 are valid
kExtFieldsValidBit = 1, // Bit to show words 64-70 are valid
kCurFieldsValidMask = (1 << kCurFieldsValidBit), // Mask for current fields valid
kExtFieldsValidMask = (1 << kExtFieldsValidBit), // Extension word valid
// Advanced PIO Transfer Modes field (word 64)
kMode3Bit = 0, // Bit to indicate mode 3 is supported
kMode3Mask = (1 << kMode3Bit), // Mask for mode 3 support
// Integrity of Identify data (word 255)
kChecksumValidCookie = 0xA5 // Bits 7:0 if device supports feature
};
/* String size constants */
enum
{
kSizeOfATAModelString = 40,
kSizeOfATARevisionString = 8
};
/* ATA Command timeout constants ( in milliseconds ) */
enum
{
kATATimeout10Seconds = 10000,
kATATimeout30Seconds = 30000,
kATATimeout45Seconds = 45000,
kATATimeout1Minute = 60000,
kATADefaultTimeout = kATATimeout30Seconds
};
/* Retry constants */
enum
{
kATAZeroRetries = 0,
kATADefaultRetries = 4
};
/* max number of blocks supported in ATA transaction */
enum
{
kIOATASectorCount8Bit = 8,
kIOATASectorCount16Bit = 16
};
enum
{
kIOATAMaximumBlockCount8Bit = (1 << kIOATASectorCount8Bit),
kIOATAMaximumBlockCount16Bit = (1 << kIOATASectorCount16Bit),
// For backwards compatibility
kIOATAMaxBlocksPerXfer = kIOATAMaximumBlockCount8Bit
};
/* Power Management time constants (in seconds) */
enum
{
kSecondsInAMinute = 60,
k5Minutes = 5 * kSecondsInAMinute
};
/* Bits for features published in Word 82 of device identify data */
enum
{
kATASupportsSMARTBit = 0,
kATASupportsPowerManagementBit = 3,
kATASupportsWriteCacheBit = 5
};
/* Masks for features published in Word 82 of device identify data */
enum
{
kATASupportsSMARTMask = (1 << kATASupportsSMARTBit),
kATASupportsPowerManagementMask = (1 << kATASupportsPowerManagementBit),
kATASupportsWriteCacheMask = (1 << kATASupportsWriteCacheBit)
};
/* Bits for features published in Word 83 of device identify data */
enum
{
kATASupportsCompactFlashBit = 2,
kATASupportsAdvancedPowerManagementBit = 3,
kATASupports48BitAddressingBit = 10,
kATASupportsFlushCacheBit = 12,
kATASupportsFlushCacheExtendedBit = 13
};
/* Masks for features published in Word 83 of device identify data */
enum
{
kATASupportsCompactFlashMask = (1 << kATASupportsCompactFlashBit),
kATASupportsAdvancedPowerManagementMask = (1 << kATASupportsAdvancedPowerManagementBit),
kATASupports48BitAddressingMask = (1 << kATASupports48BitAddressingBit),
kATASupportsFlushCacheMask = (1 << kATASupportsFlushCacheBit),
kATASupportsFlushCacheExtendedMask = (1 << kATASupportsFlushCacheExtendedBit),
// Mask to ensure data is valid
kIdentifyWordValidationMask = 0xC000,
kIdentifyWordValid = 0x4000
};
/* Bits for features published in Word 84 of device identify data */
enum
{
kATAForceUnitAccessFeatureBit = 6,
};
/* Masks for features published in Word 84 of device identify data */
enum
{
kATAForceUnitAccessFeatureMask = (1 << kATAForceUnitAccessFeatureBit),
};
/* Bits for features published in Word 85 of device identify data */
enum
{
kATAWriteCacheEnabledBit = 5
};
/* Masks for features published in Word 85 of device identify data */
enum
{
kATAWriteCacheEnabledMask = (1 << kATAWriteCacheEnabledBit)
};
/* Bits for features published in Word 106 of device identify data */
enum
{
kATAPhysicalLogicalEnabledBit0 = 15,
kATAPhysicalLogicalEnabledBit1 = 14,
kATAMultipleLogicalSectorsBit = 13,
kATAValidLogicalSectorSizeBit = 12
};
/* Masks for features published in Word 106 of device identify data */
enum
{
kATAPhysicalLogicalEnabledMask = (1 << kATAPhysicalLogicalEnabledBit0) | (1 << kATAPhysicalLogicalEnabledBit1),
kATAPhysicalLogicalEnabledValue = (0 << kATAPhysicalLogicalEnabledBit0) | (1 << kATAPhysicalLogicalEnabledBit1),
kATAMultipleLogicalSectorsMask = (1 << kATAMultipleLogicalSectorsBit),
kATAValidLogicalSectorSizeMask = (1 << kATAValidLogicalSectorSizeBit),
kATAPhysicalSectorSizeMask = 0xF,
kATALogicalSectorAlignmentMask = 0x3FFF
};
// Property table keys
#define kIOATASupportedFeaturesKey "ATA Features"
/* ATA supported features */
enum
{
kIOATAFeaturePowerManagement = 0x01, /* OBSOLETE */
kIOATAFeatureWriteCache = 0x02, /* OBSOLETE */
kIOATAFeatureAdvancedPowerManagement = 0x04,
kIOATAFeatureCompactFlash = 0x08,
kIOATAFeature48BitLBA = 0x10,
kIOATAFeatureSMART = 0x20
};
/* ATA Advanced Power Management settings (valid settings range from 1-254),
the settings below are the more common settings */
enum
{
kIOATAMaxPerformance = 0xFE,
kIOATADefaultPerformance = 0x80,
kIOATAMaxPowerSavings = 0x01
};
/* ATA Transfer Mode bit masks */
enum
{
kATAEnableUltraDMAModeMask = 0x40,
kATAEnableMultiWordDMAModeMask = 0x20,
kATAEnablePIOModeMask = 0x08
};
typedef uint32_t ATAOperationType;
enum
{
kATAOperationTypeRead = 0,
kATAOperationTypeWrite = 1,
kATAOperationTypeFlushCache = 2,
kATAOperationTypeSMART = 3,
kATAOperationTypeConfiguration = 4,
kATAOperationTypePowerManagement = 5,
kATAOperationTypeSMS = 6
};
#if defined(KERNEL)
typedef struct __ATAIORequest * ATARequestIdentifier;
#endif // defined(KERNEL)
#ifdef __cplusplus
}
#endif
#endif /* _IOKIT_IO_ATA_STORAGE_DEFINES_H_ */