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