]>
Commit | Line | Data |
---|---|---|
ee38a438 GI |
1 | /* |
2 | * ataidentify.cpp | |
3 | * | |
a86ec89e | 4 | * Home page of code is: http://www.smartmontools.org |
ee38a438 | 5 | * |
ff28b140 | 6 | * Copyright (C) 2012-18 Christian Franke |
ee38a438 | 7 | * |
ff28b140 | 8 | * SPDX-License-Identifier: GPL-2.0-or-later |
ee38a438 GI |
9 | */ |
10 | ||
11 | #include "config.h" | |
ff28b140 TL |
12 | #define __STDC_FORMAT_MACROS 1 // enable PRI* for C++ |
13 | ||
ee38a438 GI |
14 | #include "ataidentify.h" |
15 | ||
ff28b140 | 16 | const char * ataidentify_cpp_cvsid = "$Id: ataidentify.cpp 4760 2018-08-19 18:45:53Z chrfranke $" |
ee38a438 GI |
17 | ATAIDENTIFY_H_CVSID; |
18 | ||
ee38a438 GI |
19 | #include "utility.h" |
20 | ||
ff28b140 | 21 | #include <inttypes.h> |
ee38a438 GI |
22 | |
23 | // Table 12 of X3T10/0948D (ATA-2) Revision 4c, March 18, 1996 | |
24 | // Table 9 of X3T13/2008D (ATA-3) Revision 7b, January 27, 1997 | |
25 | // Tables 11 and 13 of T13/1153D (ATA/ATAPI-4) revision 18, August 19, 1998 | |
26 | // Tables 20 and 22 of T13/1321D (ATA/ATAPI-5) Revision 3, February 29, 2000 | |
27 | // Tables 27 and 29 of T13/1410D (ATA/ATAPI-6) Revision 3b, February 26, 2002 | |
28 | // Tables 16 and 18 of T13/1532D (ATA/ATAPI-7) Volume 1 Revision 4b, April 21, 2004 | |
29 | // Tables 29 and 39 of T13/1699-D (ATA8-ACS) Revision 6a, September 6, 2008 | |
30 | // Tables 50 and 61 of T13/2015-D (ACS-2) Revision 7, June 22, 2011 | |
a86ec89e | 31 | // Tables 45 and 50 of T13/2161-D (ACS-3) Revision 5, October 28, 2013 |
f9e10201 | 32 | // Table 55 of T13/BSR INCITS 529 (ACS-4) Revision 20, October 26, 2017 (ATAPI removed) |
ee38a438 GI |
33 | |
34 | const char * const identify_descriptions[] = { | |
35 | " 0 General configuration", | |
36 | ". 15 Device identifier: 0 = ATA, 1 = ATAPI", | |
37 | ". 14:8 ATA: Vendor specific [RET-3]", | |
38 | ". 14 ATAPI: Must be set to 0", | |
39 | ". 13 ATAPI: Reserved", | |
40 | ". 12:8 ATAPI: Command set: 0x05 = CD/DVD", | |
a86ec89e | 41 | ". 7 Removable media device [OBS-8]", |
ee38a438 GI |
42 | ". 6 ATA: Not removable controller and/or device [OBS-6]", |
43 | ". 5:3 ATA: Vendor specific [RET-3]", | |
44 | ". 6:5 ATAPI: DRQ after PACKET cmd: 0x0 = 3ms, 0x2 = 50us", | |
45 | ". 4:3 ATAPI: Reserved", | |
46 | ". 2 Response incomplete", | |
47 | ". 1 ATA: Vendor specific [RET-3]", | |
48 | ". 0 ATA: Reserved", | |
49 | ". 1:0 ATAPI: Packet size: 0x0 = 12 byte, 0x1 = 16 byte", | |
50 | ||
51 | " 1 Cylinders [OBS-6]", | |
52 | " 2 Specific configuration (0x37c8/738c/8c73/c837)", | |
53 | " 3 Heads [OBS-6]", | |
54 | " 4 Vendor specific [RET-3]", | |
55 | " 5 Vendor specific [RET-3]", | |
56 | " 6 Sectors per track [OBS-6]", | |
57 | " 7-8 Reserved for CFA (Sectors per card)", | |
58 | " 9 Vendor specific [RET-4]", | |
59 | " 10-19 Serial number (String)", | |
60 | " 20 Vendor specific [RET-3]", | |
61 | " 21 Vendor specific [RET-3]", | |
62 | " 22 Vendor specific bytes on READ/WRITE LONG [OBS-4]", | |
63 | " 23-26 Firmware revision (String)", | |
64 | " 27-46 Model number (String)", | |
65 | ||
66 | " 47 READ/WRITE MULTIPLE support", | |
67 | ". 15:8 Must be set to 0x80", | |
68 | ". 7:0 Maximum sectors per DRQ on READ/WRITE MULTIPLE", | |
69 | ||
70 | " 48 Trusted Computing feature set options", | |
71 | ". 15:14 Must be set to 0x1", | |
72 | ". 13:1 Reserved for the Trusted Computing Group", | |
73 | ". 0 Trusted Computing feature set supported", | |
74 | ||
75 | " 49 Capabilities", | |
76 | ". 15:14 ATA: Reserved for IDENTIFY PACKET DEVICE", | |
77 | ". 15 ATAPI: Interleaved DMA supported [OBS-8]", | |
78 | ". 14 ATAPI: Command queuing supported [OBS-8]", | |
79 | ". 13 ATA: Standard standby timer values supported", | |
80 | ". 13 ATAPI: Overlap operation supported [OBS-8]", | |
81 | ". 12 ATA: Reserved for IDENTIFY PACKET DEVICE", | |
82 | ". 12 ATAPI: ATA software reset required [OBS-5]", | |
83 | ". 11 IORDY supported", | |
84 | ". 10 IORDY may be disabled", | |
85 | ". 9 LBA supported", | |
86 | ". 8 DMA supported", | |
a86ec89e GI |
87 | ". 7:2 Reserved", // ATA-3: Vendor specific, ATA-8: Retired |
88 | ". 1:0 Long Phy Sector Alignment Error reporting", // ACS-2 | |
ee38a438 GI |
89 | |
90 | " 50 Capabilities", | |
91 | ". 15:14 Must be set to 0x1", | |
92 | ". 13:2 Reserved", | |
93 | ". 1 Reserved [OBS-6]", | |
94 | ". 0 Vendor specific minimum standby timer value", | |
95 | ||
96 | " 51 PIO data transfer mode [OBS-5]", | |
97 | " 52 Single Word DMA data transfer mode [OBS-3]", | |
98 | ||
99 | " 53 Field validity / Free-fall Control", | |
100 | ". 15:8 Free-fall Control sensitivity", | |
101 | ". 7:3 Reserved", | |
102 | ". 2 Word 88 (Ultra DMA modes) is valid", | |
103 | ". 1 Words 64-70 (PIO modes) are valid", | |
104 | ". 0 Words 54-58 (CHS) are valid [OBS-6]", | |
105 | ||
106 | " 54 Current cylinders [OBS-6]", | |
107 | " 55 Current heads [OBS-6]", | |
108 | " 56 Current sectors per track [OBS-6]", | |
109 | " 57-58 Current capacity in sectors (DWord) [OBS-6]", | |
110 | ||
111 | " 59 Sanitize Device - READ/WRITE MULTIPLE support", | |
112 | ". 15 BLOCK ERASE EXT supported", | |
113 | ". 14 OVERWRITE EXT supported", | |
114 | ". 13 CRYPTO SCRAMBLE EXT supported", | |
115 | ". 12 Sanitize Device feature set supported", | |
a86ec89e GI |
116 | ". 11 Cmds during sanitize as specified by this standard", // ACS-3 |
117 | ". 10 SANITIZE ANTIFREEZE LOCK EXT supported", // ACS-3 | |
118 | ". 9 Reserved", | |
f9e10201 JD |
119 | ". 8 Bits 7:0 are valid [OBS-ACS-4]", |
120 | ". 7:0 Current number of sectors per DRQ [OBS-ACS-4]", | |
ee38a438 GI |
121 | |
122 | " 60-61 User addressable sectors for 28-bit commands (DWord)", | |
123 | " 62 Single Word DMA modes [OBS-3]", | |
124 | ||
125 | " 63 Multiword DMA modes", | |
126 | ". 15:11 Reserved", | |
127 | ". 10 Multiword DMA mode 2 selected", | |
128 | ". 9 Multiword DMA mode 1 selected", | |
129 | ". 8 Multiword DMA mode 0 selected", | |
130 | ". 7:3 Reserved", | |
131 | ". 2 Multiword DMA mode 2 and below supported", | |
132 | ". 1 Multiword DMA mode 1 and below supported", | |
133 | ". 0 Multiword DMA mode 0 supported", | |
134 | ||
135 | " 64 PIO modes", | |
136 | ". 15:2 Reserved", | |
137 | ". 1 PIO mode 4 supported", | |
138 | ". 0 PIO mode 3 supported", | |
139 | ||
140 | " 65 Minimum Multiword DMA cycle time per word in ns", | |
141 | " 66 Recommended Multiword DMA cycle time in ns", | |
142 | " 67 Minimum PIO cycle time without flow control in ns", | |
143 | " 68 Minimum PIO cycle time with IORDY flow control in ns", | |
144 | ||
145 | " 69 Additional support", | |
146 | ". 15 CFast specification supported", | |
147 | ". 14 Deterministic data after trim supported", | |
148 | ". 13 LPS Alignment Error Reporting Control supported", | |
149 | ". 12 DCO IDENTIFY/SET DMA supported [OBS-ACS-3]", | |
150 | ". 11 READ BUFFER DMA supported", | |
151 | ". 10 WRITE BUFFER DMA supported", | |
152 | ". 9 SET MAX SET PASSWORD/UNLOCK DMA supported [OBS-ACS-3]", | |
153 | ". 8 DOWNLOAD MICROCODE DMA supported", | |
154 | ". 7 Reserved for IEEE 1667", | |
155 | ". 6 Optional ATA device 28-bit commands supported", | |
156 | ". 5 Trimmed LBA range(s) returning zeroed data supported", | |
157 | ". 4 Device encrypts all user data", | |
158 | ". 3 Extended number of user addressable sectors supported", | |
a86ec89e GI |
159 | ". 2 All write cache is non-volatile", // ACS-3 |
160 | ". 1:0 Zoned Capabilities", // ACS-4 | |
ee38a438 GI |
161 | |
162 | " 70 Reserved", | |
163 | " 71-74 ATA: Reserved for IDENTIFY PACKET DEVICE", | |
164 | " 71 ATAPI: Time in ns from PACKET to bus release [OBS-8]", | |
165 | " 72 ATAPI: Time in ns from SERVICE to BSY cleared [OBS-8]", | |
166 | " 73-74 ATAPI: Reserved", | |
167 | ||
168 | " 75 Queue depth", | |
169 | ". 15:5 Reserved", | |
170 | ". 4:0 Maximum queue depth - 1", | |
171 | ||
172 | " 76 Serial ATA capabilities", | |
173 | ". 15 READ LOG DMA EXT as equiv to READ LOG EXT supported", | |
174 | ". 14 Device Auto Partial to Slumber transitions supported", | |
175 | ". 13 Host Auto Partial to Slumber transitions supported", | |
176 | ". 12 NCQ priority information supported", | |
177 | ". 11 Unload while NCQ commands are outstanding supported", | |
178 | ". 10 Phy Event Counters supported", | |
179 | ". 9 Receipt of host initiated PM requests supported", | |
180 | ". 8 NCQ feature set supported", | |
181 | ". 7:4 Reserved for Serial ATA", | |
182 | ". 3 SATA Gen3 signaling speed (6.0 Gb/s) supported", | |
183 | ". 2 SATA Gen2 signaling speed (3.0 Gb/s) supported", | |
184 | ". 1 SATA Gen1 signaling speed (1.5 Gb/s) supported", | |
185 | ". 0 Must be set to 0", | |
186 | ||
187 | " 77 Serial ATA additional capabilities", // ACS-3 | |
f9e10201 JD |
188 | ". 15:9 Reserved for Serial ATA", |
189 | ". 8 Power Disable feature always enabled", // ACS-4 | |
190 | ". 7 DevSleep to ReducedPwrState supported", // ACS-4 | |
ee38a438 GI |
191 | ". 6 RECEIVE/SEND FPDMA QUEUED supported", |
192 | ". 5 NCQ Queue Management supported", | |
193 | ". 4 NCQ Streaming supported", | |
194 | ". 3:1 Current Serial ATA signal speed", | |
195 | ". 0 Must be set to 0", | |
196 | ||
197 | " 78 Serial ATA features supported", | |
f9e10201 JD |
198 | ". 15:13 Reserved for Serial ATA", |
199 | ". 12 Power Disable feature supported", // ACS-4 | |
200 | ". 11 Rebuild Assist feature set supported", // ACS-4 | |
201 | ". 10 Reserved for Serial ATA", | |
202 | ". 9 Hybrid Information supported", // ACS-4 | |
203 | ". 8 Device Sleep feature supported", // ACS-4 | |
ee38a438 GI |
204 | ". 7 NCQ Autosense supported", // ACS-3 |
205 | ". 6 Software Settings Preservation supported", | |
206 | ". 5 Hardware Feature Control supported", // ACS-3 | |
207 | ". 4 In-order data delivery supported", | |
208 | ". 3 Device initiated power management supported", | |
209 | ". 2 DMA Setup auto-activation supported", | |
210 | ". 1 Non-zero buffer offsets supported", | |
211 | ". 0 Must be set to 0", | |
212 | ||
213 | " 79 Serial ATA features enabled", | |
f9e10201 JD |
214 | ". 15:12 Reserved for Serial ATA", |
215 | ". 11 Rebuild Assist feature set enabled", // ACS-4 | |
216 | ". 10 Power Disable feature enabled", // ACS-4 | |
217 | ". 9 Hybrid Information enabled", // ACS-4 | |
218 | ". 8 Device Sleep feature enabled", // ACS-4 | |
ee38a438 GI |
219 | ". 7 Automatic Partial to Slumber transitions enabled", // ACS-3 |
220 | ". 6 Software Settings Preservation enabled", | |
221 | ". 5 Hardware Feature Control enabled", // ACS-3 | |
222 | ". 4 In-order data delivery enabled", | |
223 | ". 3 Device initiated power management enabled", | |
224 | ". 2 DMA Setup auto-activation enabled", | |
225 | ". 1 Non-zero buffer offsets enabled", | |
226 | ". 0 Must be set to 0", | |
227 | ||
228 | " 80 Major version number", | |
a86ec89e GI |
229 | ". 15:12 Reserved", |
230 | ". 11 ACS-4 supported", | |
ee38a438 GI |
231 | ". 10 ACS-3 supported", |
232 | ". 9 ACS-2 supported", | |
233 | ". 8 ATA8-ACS supported", | |
f9e10201 JD |
234 | ". 7 ATA/ATAPI-7 supported [OBS-ACS-4]", |
235 | ". 6 ATA/ATAPI-6 supported [OBS-ACS-4]", | |
236 | ". 5 ATA/ATAPI-5 supported [OBS-ACS-4]", | |
ee38a438 GI |
237 | ". 4 ATA/ATAPI-4 supported [OBS-8]", |
238 | ". 3 ATA-3 supported [OBS-7]", | |
239 | ". 2 ATA-2 supported [OBS-6]", | |
240 | ". 1 ATA-1 supported [OBS-5]", | |
241 | ". 0 Reserved", | |
242 | ||
243 | " 81 Minor version number", | |
244 | ||
245 | " 82 Commands and feature sets supported", | |
246 | ". 15 IDENTIFY DEVICE DMA supported [OBS-4]", // ATA-4 r07-r14 only | |
247 | ". 14 NOP supported", | |
248 | ". 13 READ BUFFER supported", | |
249 | ". 12 WRITE BUFFER supported", | |
250 | ". 11 WRITE VERIFY supported [OBS-4]", // ATA-4 r07-r13 only | |
251 | ". 10 HPA feature set supported [OBS-ACS-3]", | |
252 | ". 9 DEVICE RESET supported", // ATA:0, ATAPI:1 | |
253 | ". 8 SERVICE interrupt supported [OBS-ACS-2]", | |
254 | ". 7 Release interrupt supported [OBS-ACS-2]", | |
255 | ". 6 Read look-ahead supported", | |
256 | ". 5 Volatile write cache supported", | |
257 | ". 4 PACKET feature set supported", // ATA:0, ATAPI:1 | |
258 | ". 3 Power Management feature set supported", | |
259 | ". 2 Removable Media feature set supported [OBS-8]", | |
260 | ". 1 Security feature set supported", | |
261 | ". 0 SMART feature set supported", | |
262 | ||
263 | " 83 Commands and feature sets supported", | |
264 | ". 15:14 Must be set to 0x1", | |
265 | ". 13 FLUSH CACHE EXT supported", | |
266 | ". 12 FLUSH CACHE supported", | |
267 | ". 11 DCO feature set supported [OBS-ACS-3]", | |
268 | ". 10 48-bit Address feature set supported", | |
269 | ". 9 AAM feature set supported [OBS-ACS-2]", | |
270 | ". 8 SET MAX security extension supported [OBS-ACS-3]", | |
a86ec89e | 271 | ". 7 Reserved for Addr Offset Resvd Area Boot [OBS-ACS-3]", |
ee38a438 GI |
272 | ". 6 SET FEATURES subcommand required to spin-up", |
273 | ". 5 PUIS feature set supported", | |
274 | ". 4 Removable Media Status Notification supported [OBS-8]", | |
275 | ". 3 APM feature set supported", | |
276 | ". 2 CFA feature set supported", | |
277 | ". 1 TCQ feature set supported [OBS-ACS-2]", | |
278 | ". 0 DOWNLOAD MICROCODE supported", | |
279 | ||
280 | " 84 Commands and feature sets supported", | |
281 | ". 15:14 Must be set to 0x1", | |
282 | ". 13 IDLE IMMEDIATE with UNLOAD feature supported", | |
283 | ". 12:11 Reserved for TLC [OBS-ACS-3]", | |
284 | ". 10 URG bit for WRITE STREAM (DMA) EXT supported [OBS-8]", | |
285 | ". 9 URG bit for READ STREAM (DMA) EXT supported [OBS-8]", | |
286 | ". 8 64-bit World Wide Name supported", | |
f9e10201 | 287 | ". 7 WRITE DMA QUEUED FUA EXT supported [OBS-ACS-2]", |
ee38a438 GI |
288 | ". 6 WRITE DMA/MULTIPLE FUA EXT supported", |
289 | ". 5 GPL feature set supported", | |
f9e10201 | 290 | ". 4 Streaming feature set supported", |
ee38a438 | 291 | ". 3 Media Card Pass Through Command supported [OBS-ACS-2]", |
a86ec89e | 292 | ". 2 Media serial number supported [RES-ACS-3]", |
ee38a438 GI |
293 | ". 1 SMART self-test supported", |
294 | ". 0 SMART error logging supported", | |
295 | ||
296 | " 85 Commands and feature sets supported or enabled", | |
297 | ". 15 IDENTIFY DEVICE DMA supported [OBS-4]", // ATA-4 r07-r14 only | |
298 | ". 14 NOP supported", | |
299 | ". 13 READ BUFFER supported", | |
300 | ". 12 WRITE BUFFER supported", | |
301 | ". 11 WRITE VERIFY supported [OBS-4]", // ATA-4 r07-r13 only | |
302 | ". 10 HPA feature set supported [OBS-ACS-3]", | |
303 | ". 9 DEVICE RESET supported", // ATA:0, ATAPI:1 | |
304 | ". 8 SERVICE interrupt enabled [OBS-ACS-2]", | |
305 | ". 7 Release interrupt enabled [OBS-ACS-2]", | |
306 | ". 6 Read look-ahead enabled", | |
307 | ". 5 Write cache enabled", | |
308 | ". 4 PACKET feature set supported", // ATA:0, ATAPI:1 | |
309 | ". 3 Power Management feature set supported", | |
310 | ". 2 Removable Media feature set supported [OBS-8]", | |
311 | ". 1 Security feature set enabled", | |
312 | ". 0 SMART feature set enabled", | |
313 | ||
314 | " 86 Commands and feature sets supported or enabled", | |
315 | ". 15 Words 119-120 are valid", | |
316 | ". 14 Reserved", | |
317 | ". 13 FLUSH CACHE EXT supported", | |
318 | ". 12 FLUSH CACHE supported", | |
319 | ". 11 DCO feature set supported [OBS-ACS-3]", | |
320 | ". 10 48-bit Address features set supported", | |
321 | ". 9 AAM feature set enabled [OBS-ACS-2]", | |
322 | ". 8 SET MAX security extension enabled [OBS-ACS-3]", | |
a86ec89e | 323 | ". 7 Reserved for Addr Offset Resvd Area Boot [OBS-ACS-3]", |
ee38a438 GI |
324 | ". 6 SET FEATURES subcommand required to spin-up", |
325 | ". 5 PUIS feature set enabled", | |
326 | ". 4 Removable Media Status Notification enabled [OBS-8]", | |
327 | ". 3 APM feature set enabled", | |
328 | ". 2 CFA feature set supported", | |
329 | ". 1 TCQ feature set supported [OBS-ACS-2]", | |
330 | ". 0 DOWNLOAD MICROCODE supported", | |
331 | ||
332 | " 87 Commands and feature sets supported or enabled", | |
333 | ". 15:14 Must be set to 0x1", | |
334 | ". 13 IDLE IMMEDIATE with UNLOAD FEATURE supported", | |
335 | ". 12:11 Reserved for TLC [OBS-ACS-3]", | |
336 | ". 10 URG bit for WRITE STREAM (DMA) EXT supported [OBS-8]", | |
337 | ". 9 URG bit for READ STREAM (DMA) EXT supported [OBS-8]", | |
338 | ". 8 64-bit World Wide Name supported", | |
339 | ". 7 WRITE DMA QUEUED FUA EXT supported [OBS-ACS-2]", | |
340 | ". 6 WRITE DMA/MULTIPLE FUA EXT supported", | |
341 | ". 5 GPL feature set supported", | |
342 | ". 4 Valid CONFIGURE STREAM has been executed [OBS-8]", | |
343 | ". 3 Media Card Pass Through Command supported [OBS-ACS-2]", | |
344 | ". 2 Media serial number is valid", | |
345 | ". 1 SMART self-test supported", | |
346 | ". 0 SMART error logging supported", | |
347 | ||
348 | " 88 Ultra DMA modes", | |
349 | ". 15 Reserved", | |
350 | ". 14 Ultra DMA mode 6 selected", | |
351 | ". 13 Ultra DMA mode 5 selected", | |
352 | ". 12 Ultra DMA mode 4 selected", | |
353 | ". 11 Ultra DMA mode 3 selected", | |
354 | ". 10 Ultra DMA mode 2 selected", | |
355 | ". 9 Ultra DMA mode 1 selected", | |
356 | ". 8 Ultra DMA mode 0 selected", | |
357 | ". 7 Reserved", | |
358 | ". 6 Ultra DMA mode 6 and below supported", | |
359 | ". 5 Ultra DMA mode 5 and below supported", | |
360 | ". 4 Ultra DMA mode 4 and below supported", | |
361 | ". 3 Ultra DMA mode 3 and below supported", | |
362 | ". 2 Ultra DMA mode 2 and below supported", | |
363 | ". 1 Ultra DMA mode 1 and below supported", | |
364 | ". 0 Ultra DMA mode 0 supported", | |
365 | ||
366 | " 89 SECURITY ERASE UNIT time", | |
a86ec89e GI |
367 | ". 15 Bits 14:8 of value are valid", // ACS-3 |
368 | ". 14:0 SECURITY ERASE UNIT time value", // value*2 minutes | |
369 | ||
ee38a438 | 370 | " 90 ENHANCED SECURITY ERASE UNIT time", |
a86ec89e GI |
371 | ". 15 Bits 14:8 of value are valid", // ACS-3 |
372 | ". 14:0 ENHANCED SECURITY ERASE UNIT time value", // value*2 minutes | |
373 | ||
ee38a438 | 374 | " 91 Current APM level", |
a86ec89e GI |
375 | ". 15:8 Reserved", // ACS-3 |
376 | ". 7:0 Current APM level value", | |
377 | ||
378 | " 92 Master Password Identifier", // ATA-7: Master Password Revision Code | |
ee38a438 GI |
379 | |
380 | " 93 Hardware reset result (PATA)", | |
381 | ". 15:14 Must be set to 0x1", | |
382 | ". 13 Device detected CBLID- above(1)/below(0) ViHB", | |
383 | ". 12 Reserved", | |
384 | ". 11 Device 1 asserted PDIAG-", | |
385 | ". 10:9 Device 1 detection method: -, Jumper, CSEL, other", | |
386 | ". 8 Must be set to 1", | |
387 | ". 7 Reserved", | |
388 | ". 6 Device 0 responds when device 1 selected", | |
389 | ". 5 Device 0 detected the assertion of DASP-", | |
390 | ". 4 Device 0 detected the assertion of PDIAG-", | |
391 | ". 3 Device 0 passed diagnostics", | |
392 | ". 2:1 Device 0 detection method: -, Jumper, CSEL, other", | |
393 | ". 0 Must be set to 1", | |
394 | ||
395 | " 94 AAM level [OBS-ACS-2]", | |
396 | ". 15:8 Recommended AAM level [OBS-ACS-2]", | |
397 | ". 7:0 Current AAM level [OBS-ACS-2]", | |
398 | ||
399 | " 95 Stream Minimum Request Size", | |
400 | " 96 Streaming Transfer Time - DMA", | |
401 | " 97 Streaming Access Latency - DMA and PIO", | |
402 | " 98-99 Streaming Performance Granularity (DWord)", | |
403 | "100-103 User addressable sectors for 48-bit commands (QWord)", | |
404 | "104 Streaming Transfer Time - PIO", | |
405 | "105 Max blocks of LBA Range Entries per DS MANAGEMENT cmd", | |
406 | ||
407 | "106 Physical sector size / logical sector size", | |
408 | ". 15:14 Must be set to 0x1", | |
409 | ". 13 Multiple logical sectors per physical sector", | |
410 | ". 12 Logical Sector longer than 256 words", | |
411 | ". 11:4 Reserved", | |
412 | ". 3:0 2^X logical sectors per physical sector", | |
413 | ||
414 | "107 Inter-seek delay for ISO 7779 acoustic testing", | |
f9e10201 | 415 | "108-111 World Wide Name", |
a86ec89e | 416 | "112-115 Reserved", // ATA-7: Reserved for world wide name extension to 128 bits |
ee38a438 GI |
417 | "116 Reserved for TLC [OBS-ACS-3]", |
418 | "117-118 Logical sector size (DWord)", | |
419 | ||
420 | "119 Commands and feature sets supported", | |
421 | ". 15:14 Must be set to 0x1", | |
422 | ". 13:10 Reserved", | |
423 | ". 9 DSN feature set supported", // ACS-3 | |
424 | ". 8 Accessible Max Address Config feature set supported", // ACS-3 | |
425 | ". 7 Extended Power Conditions feature set supported", | |
426 | ". 6 Sense Data Reporting feature set supported", | |
427 | ". 5 Free-fall Control feature set supported", | |
428 | ". 4 DOWNLOAD MICROCODE with mode 3 supported", | |
429 | ". 3 READ/WRITE LOG DMA EXT supported", | |
430 | ". 2 WRITE UNCORRECTABLE EXT supported", | |
431 | ". 1 Write-Read-Verify feature set supported", | |
432 | ". 0 Reserved for DDT [OBS-ACS-3]", | |
433 | ||
434 | "120 Commands and feature sets supported or enabled", | |
435 | ". 15:14 Must be set to 0x1", | |
436 | ". 13:10 Reserved", | |
437 | ". 9 DSN feature set enabled", // ACS-3 | |
438 | ". 8 Reserved", | |
439 | ". 7 Extended Power Conditions feature set enabled", | |
440 | ". 6 Sense Data Reporting feature set enabled", | |
441 | ". 5 Free-fall Control feature set enabled", | |
442 | ". 4 DOWNLOAD MICROCODE with mode 3 supported", | |
443 | ". 3 READ/WRITE LOG DMA EXT supported", | |
444 | ". 2 WRITE UNCORRECTABLE EXT supported", | |
445 | ". 1 Write-Read-Verify feature set enabled", | |
446 | ". 0 Reserved for DDT [OBS-ACS-3]", | |
447 | ||
448 | "121-126 ATA: Reserved", | |
449 | "121-124 ATAPI: Reserved", | |
450 | "125 ATAPI: Byte count = 0 behavior", | |
451 | "126 ATAPI: Byte count = 0 behavior [OBS-6]", | |
452 | ||
453 | "127 Removable Media Status Notification [OBS-8]", | |
454 | ". 15:1 Reserved", | |
455 | ". 0 Removable Media Status Notification supported", | |
456 | ||
457 | "128 Security status", | |
458 | ". 15:9 Reserved", | |
459 | ". 8 Master password capability: 0 = High, 1 = Maximum", | |
460 | ". 7:6 Reserved", | |
461 | ". 5 Enhanced security erase supported", | |
462 | ". 4 Security count expired", | |
463 | ". 3 Security frozen", | |
464 | ". 2 Security locked", | |
465 | ". 1 Security enabled", | |
466 | ". 0 Security supported", | |
467 | ||
468 | "129-159 Vendor specific", | |
469 | ||
470 | "160 CFA power mode", | |
471 | // ". 15 Word 160 supported", | |
472 | // ". 14 Reserved", | |
473 | // ". 13 CFA power mode 1 is required for some commands", | |
474 | // ". 12 CFA power mode 1 disabled", | |
475 | // ". 11:0 Maximum current in mA", | |
476 | "161-167 Reserved for CFA", | |
477 | ||
478 | "168 Form factor", | |
479 | ". 15:4 Reserved", | |
f9e10201 | 480 | ". 3:0 Nominal form factor: -, 5.25, 3.5, 2.5, 1.8, ...", // <1.8, ACS-4: mSATA, M.2, ... |
ee38a438 | 481 | |
a86ec89e | 482 | "169 DATA SET MANAGEMENT command support", |
ee38a438 GI |
483 | ". 15:1 Reserved", |
484 | ". 0 Trim bit in DATA SET MANAGEMENT command supported", | |
485 | ||
486 | "170-173 Additional product identifier (String)", | |
487 | "174-175 Reserved", | |
488 | "176-205 Current media serial number (String)", | |
489 | ||
490 | "206 SCT Command Transport", | |
a86ec89e | 491 | ". 15:12 Vendor specific", |
ee38a438 GI |
492 | ". 11:8 Reserved", |
493 | ". 7 Reserved for Serial ATA", | |
494 | ". 6 Reserved", | |
495 | ". 5 SCT Data Tables supported", | |
496 | ". 4 SCT Feature Control supported", | |
497 | ". 3 SCT Error Recovery Control supported", | |
498 | ". 2 SCT Write Same supported", | |
499 | ". 1 SCT Read/Write Long supported [OBS-ACS-2]", | |
500 | ". 0 SCT Command Transport supported", | |
501 | ||
a86ec89e | 502 | "207-208 Reserved", // ATA-8: Reserved for CE-ATA |
ee38a438 GI |
503 | |
504 | "209 Alignment of logical sectors", | |
505 | ". 15:14 Must be set to 0x1", | |
506 | ". 13:0 Logical sector offset", | |
507 | ||
508 | "210-211 Write-Read-Verify sector count mode 3 (DWord)", | |
509 | "212-213 Write-Read-Verify sector count mode 2 (DWord)", | |
510 | ||
511 | "214 NV Cache capabilities [OBS-ACS-3]", | |
512 | ". 15:12 NV Cache feature set version [OBS-ACS-3]", | |
513 | ". 11:8 NV Cache Power Mode feature set version [OBS-ACS-3]", | |
514 | ". 7:5 Reserved [OBS-ACS-3]", | |
515 | ". 4 NV Cache feature set enabled [OBS-ACS-3]", | |
516 | ". 3:2 Reserved", | |
517 | ". 1 NV Cache Power Mode feature set enabled [OBS-ACS-3]", | |
518 | ". 0 NV Cache Power Mode feature set supported [OBS-ACS-3]", | |
519 | ||
520 | "215-216 NV Cache size in logical blocks (DWord) [OBS-ACS-3]", | |
521 | "217 Nominal media rotation rate", | |
522 | "218 Reserved", | |
523 | ||
524 | "219 NV Cache options [OBS-ACS-3]", | |
525 | ". 15:8 Reserved [OBS-ACS-3]", | |
526 | ". 7:0 Estimated time to spin up in seconds [OBS-ACS-3]", | |
527 | ||
528 | "220 Write-Read-Verify mode", | |
529 | ". 15:8 Reserved", | |
530 | ". 7:0 Write-Read-Verify feature set current mode", | |
531 | ||
532 | "221 Reserved", | |
533 | ||
534 | "222 Transport major version number", | |
a86ec89e | 535 | ". 15:12 Transport: 0x0 = Parallel, 0x1 = Serial, 0xe = PCIe", // PCIe: ACS-4 |
f9e10201 JD |
536 | ". 11:9 Reserved | Reserved", |
537 | ". 8 Reserved | SATA 3.3", // ACS-4 | |
538 | ". 7 Reserved | SATA 3.2", // ACS-4 | |
539 | ". 6 Reserved | SATA 3.1", // ACS-3 | |
540 | ". 5 Reserved | SATA 3.0", // ACS-2 | |
ee38a438 GI |
541 | ". 4 Reserved | SATA 2.6", |
542 | ". 3 Reserved | SATA 2.5", | |
543 | ". 2 Reserved | SATA II: Extensions", | |
544 | ". 1 ATA/ATAPI-7 | SATA 1.0a", | |
545 | ". 0 ATA8-APT | ATA8-AST", | |
546 | ||
547 | "223 Transport minor version number", | |
548 | "224-229 Reserved", | |
549 | "230-233 Extended number of user addressable sectors (QWord)", | |
550 | "234 Minimum blocks per DOWNLOAD MICROCODE mode 3 command", | |
551 | "235 Maximum blocks per DOWNLOAD MICROCODE mode 3 command", | |
552 | "236-254 Reserved", | |
553 | ||
554 | "255 Integrity word", | |
555 | ". 15:8 Checksum", | |
556 | ". 7:0 Signature" | |
557 | }; | |
558 | ||
559 | const int num_identify_descriptions = sizeof(identify_descriptions)/sizeof(identify_descriptions[0]); | |
560 | ||
561 | static inline unsigned short get_word(const void * id, int word) | |
562 | { | |
563 | const unsigned char * p = ((const unsigned char *)id) + 2 * word; | |
564 | return p[0] + (p[1] << 8); | |
565 | } | |
566 | ||
567 | void ata_print_identify_data(const void * id, bool all_words, int bit_level) | |
568 | { | |
569 | // ATA or ATAPI ? | |
570 | unsigned short w = get_word(id, 0); | |
571 | bool is_atapi = ((w & 0x8000) && (w != 0x848a/*CompactFlash Signature*/)); | |
572 | ||
573 | int prev_word = -1, prev_bit = -1; | |
574 | pout("Word %s Value Description\n", (bit_level >= 0 ? "Bit " : " ")); | |
575 | ||
576 | for (int i = 0; i < num_identify_descriptions; i++) { | |
577 | // Parse table entry | |
578 | const char * desc = identify_descriptions[i]; | |
579 | ||
580 | int word = prev_word, word2 = -1; | |
581 | int bit = -1, bit2 = -1; | |
582 | ||
583 | int nc; | |
584 | unsigned v1, v2; | |
585 | if (word >= 0 && sscanf(desc, ". %u:%u %n", &v1, &v2, (nc=-1, &nc)) == 2 && nc > 0 && 16 > v1 && v1 > v2) { | |
586 | bit = v1; bit2 = v2; | |
587 | } | |
588 | else if (word >= 0 && sscanf(desc, ". %u %n", &v1, (nc=-1, &nc)) == 1 && nc > 0 && v1 < 16) { | |
589 | bit = v1; | |
590 | } | |
591 | else if (sscanf(desc, "%u-%u %n", &v1, &v2, (nc=-1, &nc)) == 2 && nc > 0 && v1 < v2 && v2 < 256) { | |
592 | word = v1, word2 = v2; | |
593 | } | |
594 | else if (sscanf(desc, "%u %n", &v1, (nc=-1, &nc)) == 1 && nc > 0 && v1 < 256) { | |
595 | word = v1; | |
596 | } | |
597 | else { | |
598 | pout("Error: #%d: Syntax\n", i); | |
599 | continue; | |
600 | } | |
601 | desc += nc; | |
602 | ||
603 | // Check for ATA/ATAPI specific entries | |
604 | if (str_starts_with(desc, "ATA: ")) { | |
605 | if (is_atapi) | |
606 | continue; | |
607 | desc += sizeof("ATA: ")-1; | |
608 | } | |
609 | else if (str_starts_with(desc, "ATAPI: ")) { | |
610 | if (!is_atapi) | |
611 | continue; | |
612 | } | |
613 | ||
614 | // Check table entry | |
615 | if (bit < 0) { | |
616 | if (word != prev_word+1) { | |
617 | pout("Error: #%d: Missing word %d\n", i, prev_word+1); | |
618 | return; | |
619 | } | |
620 | else if (prev_bit > 0) { | |
621 | pout("Error: #%d: Missing bit 0 from word %d\n", i, prev_word); | |
622 | return; | |
623 | } | |
624 | } | |
625 | else if (!((prev_bit < 0 && bit == 15) || bit == prev_bit-1)) { | |
626 | pout("Error: #%d: Missing bit %d from word %d\n", i, bit+1, word); | |
627 | return; | |
628 | } | |
629 | ||
630 | w = get_word(id, word); | |
631 | bool w_is_set = (w != 0x0000 && w != 0xffff); | |
632 | ||
633 | if (bit >= 0) { | |
634 | int b; | |
635 | if (bit2 >= 0) | |
f9e10201 | 636 | b = (w >> bit2) & ~(~0U << (bit-bit2+1)); |
ee38a438 GI |
637 | else |
638 | b = (w >> bit) & 1; | |
639 | ||
640 | if ( (bit_level >= 0 && b) | |
641 | || (bit_level >= 1 && w_is_set) | |
642 | || (bit_level >= 2 && all_words)) { | |
643 | if (bit2 >= 0) { | |
644 | // Print bitfield | |
645 | char valstr[20]; | |
646 | snprintf(valstr, sizeof(valstr), "0x%0*x", (bit - bit2 + 4) >> 2, b); | |
647 | pout("%4d %2d:%-2d %6s %s\n", word, bit, bit2, valstr, desc); | |
648 | } | |
649 | else { | |
650 | // Print bit | |
651 | pout("%4d %2d %u %s\n", word, bit, b, desc); | |
652 | } | |
653 | } | |
654 | ||
655 | prev_bit = (bit2 >= 0 ? bit2 : bit); | |
656 | } | |
657 | else { | |
658 | if (word2 >= 0) { | |
659 | for (int j = word+1; !w_is_set && j <= word2; j++) { | |
660 | if (get_word(id, j) != w) | |
661 | w_is_set = true; | |
662 | } | |
663 | ||
664 | // Print word array | |
665 | if (all_words || w_is_set) { | |
666 | pout("%s%4d-%-3d %s", | |
667 | (bit_level >= 0 ? "\n" : ""), word, word2, | |
668 | (bit_level >= 0 ? "- " : "")); | |
669 | ||
670 | if (!w_is_set) { | |
671 | pout("0x%02x... %s\n", w & 0xff, desc); | |
672 | } | |
673 | else { | |
674 | bool is_str = !!strstr(desc, "(String)"); | |
675 | pout(". %s", desc); | |
676 | ||
677 | for (int j = word; j <= word2; j += 4) { | |
678 | if (j + 2*4 < word2 && !nonempty((const unsigned char *)id + 2*j, 2*(word2-j+1))) { | |
679 | // Remaining words are null | |
680 | pout("\n%4d-%-3d %s0x0000:0000:0000:00...", j, word2, | |
681 | (bit_level >= 0 ? ". " : "")); | |
682 | break; | |
683 | } | |
684 | // Print 4 words in a row | |
685 | pout("\n%4d-%-3d %s0x", j, (j+3 <= word2 ? j+3 : word2), | |
686 | (bit_level >= 0 ? ". " : "")); | |
687 | int k; | |
688 | for (k = 0; k < 4 && j+k <= word2; k++) | |
689 | pout("%s%04x", (k == 0 ? "" : ":"), get_word(id, j+k)); | |
690 | ||
691 | if (is_str) { | |
692 | // Append little endian string | |
693 | pout("%*s \"", 20 - 5 * k, ""); | |
694 | for (k = 0; k < 4 && j+k <= word2; k++) { | |
695 | char c2 = ((const char *)id)[2*(j+k) ]; | |
696 | char c1 = ((const char *)id)[2*(j+k) + 1]; | |
697 | pout("%c%c", (' ' <= c1 && c1 <= '~' ? c1 : '.'), | |
698 | (' ' <= c2 && c2 <= '~' ? c2 : '.') ); | |
699 | } | |
700 | pout("\""); | |
701 | } | |
702 | } | |
703 | ||
704 | // Print decimal value of D/QWords | |
705 | if (word + 1 == word2 && strstr(desc, "(DWord)")) | |
706 | pout(" (%u)\n", ((unsigned)get_word(id, word2) << 16) | w); | |
707 | else if (word + 3 == word2 && strstr(desc, "(QWord)")) | |
d2e702cf GI |
708 | pout(" (%" PRIu64 ")\n", ((uint64_t)get_word(id, word + 3) << 48) |
709 | | ((uint64_t)get_word(id, word + 2) << 32) | |
710 | | ((unsigned)get_word(id, word + 1) << 16) | (unsigned)w); | |
ee38a438 GI |
711 | else |
712 | pout("\n"); | |
713 | } | |
714 | } | |
715 | } | |
716 | else { | |
717 | // Print word | |
718 | if (all_words || w_is_set) | |
719 | pout("%s%4d %s0x%04x %s\n", | |
720 | (bit_level >= 0 ? "\n" : ""), word, | |
721 | (bit_level >= 0 ? "- " : ""), w, desc); | |
722 | } | |
723 | ||
724 | prev_word = (word2 >= 0 ? word2 : word); | |
725 | prev_bit = -1; | |
726 | } | |
727 | } | |
728 | ||
729 | pout("\n"); | |
730 | } |