smartmontools  SVN Rev 4834
Utility to control and monitor storage systems with "S.M.A.R.T."
atacmdnames.cpp
Go to the documentation of this file.
1 /*
2  * atacmdnames.cpp
3  *
4  * Home page of code is: http://www.smartmontools.org
5  *
6  * Copyright (C) 2003-8 Philip Williams
7  * Copyright (C) 2012 Christian Franke
8  *
9  * SPDX-License-Identifier: GPL-2.0-or-later
10  */
11 
12 #include "atacmdnames.h"
13 #include <stdlib.h>
14 #include <stdio.h>
15 
16 const char * atacmdnames_cpp_cvsid = "$Id: atacmdnames.cpp 4760 2018-08-19 18:45:53Z chrfranke $"
18 
19 const char cmd_reserved[] = "[RESERVED]";
20 const char cmd_vendor_specific[] = "[VENDOR SPECIFIC]";
21 const char cmd_reserved_sa[] = "[RESERVED FOR SERIAL ATA]";
22 const char cmd_reserved_cf[] = "[RESERVED FOR COMPACTFLASH ASSOCIATION]";
23 const char cmd_reserved_mcpt[] = "[RESERVED FOR MEDIA CARD PASS THROUGH]"; // ACS-3: Reserved
24 const char cmd_recalibrate_ret4[]= "RECALIBRATE [RET-4]";
25 const char cmd_seek_ret4[] = "SEEK [RET-4]";
26 
27 // Tables B.3 and B.4 of T13/2161-D (ACS-3) Revision 4, September 4, 2012
28 
29 const char * const command_table[] = {
30 /*-------------------------------------------------- 00h-0Fh -----*/
31  "NOP",
34  "CFA REQUEST EXTENDED ERROR",
37  "DATA SET MANAGEMENT", // ACS-2
39  "DEVICE RESET",
42  "REQUEST SENSE DATA EXT", // ACS-2
47 /*-------------------------------------------------- 10h-1Fh -----*/
48  "RECALIBRATE [OBS-4]",
64 /*-------------------------------------------------- 20h-2Fh -----*/
65  "READ SECTOR(S)",
66  "READ SECTOR(S) [OBS-5]",
67  "READ LONG [OBS-4]",
68  "READ LONG (w/o retry) [OBS-4]",
69  "READ SECTOR(S) EXT",
70  "READ DMA EXT",
71  "READ DMA QUEUED EXT [OBS-ACS-2]",
72  "READ NATIVE MAX ADDRESS EXT [OBS-ACS-3]",
74  "READ MULTIPLE EXT",
75  "READ STREAM DMA",
76  "READ STREAM",
80  "READ LOG EXT",
81 /*-------------------------------------------------- 30h-3Fh -----*/
82  "WRITE SECTOR(S)",
83  "WRITE SECTOR(S) (w/o retry) [OBS-5]",
84  "WRITE LONG [OBS-4]",
85  "WRITE LONG (w/o retry) [OBS-4]",
86  "WRITE SECTORS(S) EXT",
87  "WRITE DMA EXT",
88  "WRITE DMA QUEUED EXT [OBS-ACS-2]",
89  "SET NATIVE MAX ADDRESS EXT [OBS-ACS-3]",
90  "CFA WRITE SECTORS WITHOUT ERASE",
91  "WRITE MULTIPLE EXT",
92  "WRITE STREAM DMA",
93  "WRITE STREAM",
94  "WRITE VERIFY [OBS-4]",
95  "WRITE DMA FUA EXT",
96  "WRITE DMA QUEUED FUA EXT [OBS-ACS-2]",
97  "WRITE LOG EXT",
98 /*-------------------------------------------------- 40h-4Fh -----*/
99  "READ VERIFY SECTOR(S)",
100  "READ VERIFY SECTOR(S) (w/o retry) [OBS-5]",
101  "READ VERIFY SECTOR(S) EXT",
102  cmd_reserved,
103  cmd_reserved,
104  "WRITE UNCORRECTABLE EXT", // ATA-8
105  cmd_reserved,
106  "READ LOG DMA EXT", // ATA-8
107  cmd_reserved,
108  cmd_reserved,
109  cmd_reserved,
110  cmd_reserved,
111  cmd_reserved,
112  cmd_reserved,
113  cmd_reserved,
114  cmd_reserved,
115 /*-------------------------------------------------- 50h-5Fh -----*/
116  "FORMAT TRACK [OBS-4]",
117  "CONFIGURE STREAM",
118  cmd_reserved,
119  cmd_reserved,
120  cmd_reserved,
121  cmd_reserved,
122  cmd_reserved,
123  "WRITE LOG DMA EXT", // ATA-8
124  cmd_reserved,
125  cmd_reserved,
126  cmd_reserved,
127  "TRUSTED NON-DATA", // ATA-8
128  "TRUSTED RECEIVE", // ATA-8
129  "TRUSTED RECEIVE DMA", // ATA-8
130  "TRUSTED SEND", // ATA-8
131  "TRUSTED SEND DMA", // ATA-8
132 /*-------------------------------------------------- 60h-6Fh -----*/
133  "READ FPDMA QUEUED", // ATA-8
134  "WRITE FPDMA QUEUED", // ATA-8
136  "NCQ QUEUE MANAGEMENT", // ACS-3
137  "SEND FPDMA QUEUED", // ACS-3
138  "RECEIVE FPDMA QUEUED", // ACS-3
141  cmd_reserved,
142  cmd_reserved,
143  cmd_reserved,
144  cmd_reserved,
145  cmd_reserved,
146  cmd_reserved,
147  cmd_reserved,
148  cmd_reserved,
149 /*-------------------------------------------------- 70h-7Fh -----*/
150  "SEEK [OBS-7]",
157  "SET DATE & TIME EXT", // ACS-3
158  "ACCESSIBLE MAX ADDRESS CONFIGURATION", // ACS-3
166 /*-------------------------------------------------- 80h-8Fh -----*/
174  "CFA TRANSLATE SECTOR [VS IF NO CFA]",
183 /*-------------------------------------------------- 90h-9Fh -----*/
184  "EXECUTE DEVICE DIAGNOSTIC",
185  "INITIALIZE DEVICE PARAMETERS [OBS-6]",
186  "DOWNLOAD MICROCODE",
187  "DOWNLOAD MICROCODE DMA", // ACS-2
188  "STANDBY IMMEDIATE [RET-4]",
189  "IDLE IMMEDIATE [RET-4]",
190  "STANDBY [RET-4]",
191  "IDLE [RET-4]",
192  "CHECK POWER MODE [RET-4]",
193  "SLEEP [RET-4]",
195  cmd_reserved,
196  cmd_reserved,
197  cmd_reserved,
198  cmd_reserved,
199  cmd_reserved,
200 /*-------------------------------------------------- A0h-AFh -----*/
201  "PACKET",
202  "IDENTIFY PACKET DEVICE",
203  "SERVICE [OBS-ACS-2]",
204  cmd_reserved,
205  cmd_reserved,
206  cmd_reserved,
207  cmd_reserved,
208  cmd_reserved,
209  cmd_reserved,
210  cmd_reserved,
211  cmd_reserved,
212  cmd_reserved,
213  cmd_reserved,
214  cmd_reserved,
215  cmd_reserved,
216  cmd_reserved,
217 /*-------------------------------------------------- B0h-BFh -----*/
218  "SMART",
219  "DEVICE CONFIGURATION [OBS-ACS-3]",
220  cmd_reserved,
221  cmd_reserved,
222  "SANITIZE DEVICE", // ACS-2
223  cmd_reserved,
224  "NV CACHE [OBS-ACS-3]", // ATA-8
230  cmd_reserved,
231  cmd_reserved,
232  cmd_reserved,
233  cmd_reserved,
234 /*-------------------------------------------------- C0h-CFh -----*/
235  "CFA ERASE SECTORS [VS IF NO CFA]",
239  "READ MULTIPLE",
240  "WRITE MULTIPLE",
241  "SET MULTIPLE MODE",
242  "READ DMA QUEUED [OBS-ACS-2]",
243  "READ DMA",
244  "READ DMA (w/o retry) [OBS-5]",
245  "WRITE DMA",
246  "WRITE DMA (w/o retry) [OBS-5]",
247  "WRITE DMA QUEUED [OBS-ACS-2]",
248  "CFA WRITE MULTIPLE WITHOUT ERASE",
249  "WRITE MULTIPLE FUA EXT",
250  cmd_reserved,
251 /*-------------------------------------------------- D0h-DFh -----*/
252  cmd_reserved,
253  "CHECK MEDIA CARD TYPE [OBS-ACS-2]",
257  cmd_reserved,
258  cmd_reserved,
259  cmd_reserved,
260  cmd_reserved,
261  cmd_reserved,
262  "GET MEDIA STATUS [OBS-8]",
263  "ACKNOWLEDGE MEDIA CHANGE [RET-4]",
264  "BOOT POST-BOOT [RET-4]",
265  "BOOT PRE-BOOT [RET-4]",
266  "MEDIA LOCK [OBS-8]",
267  "MEDIA UNLOCK [OBS-8]",
268 /*-------------------------------------------------- E0h-EFh -----*/
269  "STANDBY IMMEDIATE",
270  "IDLE IMMEDIATE",
271  "STANDBY",
272  "IDLE",
273  "READ BUFFER",
274  "CHECK POWER MODE",
275  "SLEEP",
276  "FLUSH CACHE",
277  "WRITE BUFFER",
278  "READ BUFFER DMA", // ACS-2 (was: WRITE SAME [RET-4])
279  "FLUSH CACHE EXT",
280  "WRITE BUFFER DMA", // ACS-2
281  "IDENTIFY DEVICE",
282  "MEDIA EJECT [OBS-8]",
283  "IDENTIFY DEVICE DMA [OBS-4]",
284  "SET FEATURES",
285 /*-------------------------------------------------- F0h-FFh -----*/
287  "SECURITY SET PASSWORD",
288  "SECURITY UNLOCK",
289  "SECURITY ERASE PREPARE",
290  "SECURITY ERASE UNIT",
291  "SECURITY FREEZE LOCK",
292  "SECURITY DISABLE PASSWORD",
294  "READ NATIVE MAX ADDRESS [OBS-ACS-3]",
295  "SET MAX ADDRESS [OBS-ACS-3]",
301  cmd_vendor_specific
302 };
303 
304 typedef char ASSERT_command_table_size[
305  sizeof(command_table)/sizeof(command_table[0]) == 256 ? 1 : -1];
306 
307 /* Returns the name of the command (and possibly sub-command) with the given
308  command code and feature register values. For most command codes this
309  simply returns the corresponding entry in the command_table array, but for
310  others the value of the feature register specifies a subcommand or
311  distinguishes commands. */
312 const char *look_up_ata_command(unsigned char c_code, unsigned char f_reg) {
313 
314  switch (c_code) {
315  case 0x00: /* NOP */
316  switch (f_reg) {
317  case 0x00:
318  return "NOP [Abort queued commands]";
319  case 0x01:
320  return "NOP [Don't abort queued commands] [OBS-ACS-2]";
321  default:
322  return "NOP [Reserved subcommand] [OBS-ACS-2]";
323  }
324  case 0x92: /* DOWNLOAD MICROCODE */
325  switch (f_reg) {
326  case 0x01:
327  return "DOWNLOAD MICROCODE [Temporary] [OBS-8]";
328  case 0x03:
329  return "DOWNLOAD MICROCODE [Save with offsets]"; // ATA-8
330  case 0x07:
331  return "DOWNLOAD MICROCODE [Save]";
332  case 0x0e:
333  return "DOWNLOAD MICROCODE [Save for future use]"; // ACS-3
334  case 0x0f:
335  return "DOWNLOAD MICROCODE [Activate]"; // ACS-3
336  default:
337  return "DOWNLOAD MICROCODE [Reserved subcommand]";
338  }
339  case 0xB0: /* SMART */
340  switch (f_reg) {
341  case 0xD0:
342  return "SMART READ DATA";
343  case 0xD1:
344  return "SMART READ ATTRIBUTE THRESHOLDS [OBS-4]";
345  case 0xD2:
346  return "SMART ENABLE/DISABLE ATTRIBUTE AUTOSAVE";
347  case 0xD3:
348  return "SMART SAVE ATTRIBUTE VALUES [OBS-6]";
349  case 0xD4:
350  return "SMART EXECUTE OFF-LINE IMMEDIATE";
351  case 0xD5:
352  return "SMART READ LOG";
353  case 0xD6:
354  return "SMART WRITE LOG";
355  case 0xD7:
356  return "SMART WRITE ATTRIBUTE THRESHOLDS [NS, OBS-4]";
357  case 0xD8:
358  return "SMART ENABLE OPERATIONS";
359  case 0xD9:
360  return "SMART DISABLE OPERATIONS";
361  case 0xDA:
362  return "SMART RETURN STATUS";
363  case 0xDB:
364  return "SMART EN/DISABLE AUTO OFFLINE [NS (SFF-8035i)]";
365  default:
366  if (f_reg >= 0xE0)
367  return "SMART [Vendor specific subcommand]";
368  else
369  return "SMART [Reserved subcommand]";
370  }
371  case 0xB1: /* DEVICE CONFIGURATION */
372  switch (f_reg) {
373  case 0xC0:
374  return "DEVICE CONFIGURATION RESTORE [OBS-ACS-3]";
375  case 0xC1:
376  return "DEVICE CONFIGURATION FREEZE LOCK [OBS-ACS-3]";
377  case 0xC2:
378  return "DEVICE CONFIGURATION IDENTIFY [OBS-ACS-3]";
379  case 0xC3:
380  return "DEVICE CONFIGURATION SET [OBS-ACS-3]";
381  default:
382  return "DEVICE CONFIGURATION [Reserved subcommand] [OBS-ACS-3]";
383  }
384  case 0xEF: /* SET FEATURES */
385  switch (f_reg) {
386  case 0x01:
387  return "SET FEATURES [Enable 8-bit PIO] [OBS-3]"; // Now CFA
388  case 0x02:
389  return "SET FEATURES [Enable write cache]";
390  case 0x03:
391  return "SET FEATURES [Set transfer mode]";
392  case 0x04:
393  return "SET FEATURES [Enable auto DR] [OBS-4]";
394  case 0x05:
395  return "SET FEATURES [Enable APM]";
396  case 0x06:
397  return "SET FEATURES [Enable Pwr-Up In Standby]";
398  case 0x07:
399  return "SET FEATURES [Set device spin-up]";
400  case 0x09:
401  return "SET FEATURES [Reserved (address offset)] [OPS-ACS-3]";
402  case 0x0A:
403  return "SET FEATURES [Enable CFA power mode 1]";
404  case 0x10:
405  return "SET FEATURES [Enable SATA feature]"; // ACS-3
406  case 0x20:
407  return "SET FEATURES [Set Time-ltd R/W WCT]";
408  case 0x21:
409  return "SET FEATURES [Set Time-ltd R/W EH]";
410  case 0x31:
411  return "SET FEATURES [Disable Media Status Notf] [OBS-8]";
412  case 0x33:
413  return "SET FEATURES [Disable retry] [OBS-4]";
414  case 0x41:
415  return "SET FEATURES [Enable Free-fall Control]"; // ATA-8
416  case 0x42:
417  return "SET FEATURES [Enable AAM] [OBS-ACS-2]";
418  case 0x43:
419  return "SET FEATURES [Set Max Host I/F S Times]";
420  case 0x44:
421  return "SET FEATURES [Length of VS data] [OBS-4]";
422  case 0x4a:
423  return "SET FEATURES [Ext. Power Conditions]"; // ACS-2
424  case 0x54:
425  return "SET FEATURES [Set cache segs] [OBS-4]";
426  case 0x55:
427  return "SET FEATURES [Disable read look-ahead]";
428  case 0x5D:
429  return "SET FEATURES [Enable release interrupt] [OBS-ACS-2]";
430  case 0x5E:
431  return "SET FEATURES [Enable SERVICE interrupt] [OBS-ACS-2]";
432  case 0x66:
433  return "SET FEATURES [Disable revert defaults]";
434  case 0x69:
435  return "SET FEATURES [LPS Error Reporting Control]"; // ACS-2
436  case 0x77:
437  return "SET FEATURES [Disable ECC] [OBS-4]";
438  case 0x81:
439  return "SET FEATURES [Disable 8-bit PIO] [OBS-3]"; // Now CFA
440  case 0x82:
441  return "SET FEATURES [Disable write cache]";
442  case 0x84:
443  return "SET FEATURES [Disable auto DR] [OBS-4]";
444  case 0x85:
445  return "SET FEATURES [Disable APM]";
446  case 0x86:
447  return "SET FEATURES [Disable Pwr-Up In Standby]";
448  case 0x88:
449  return "SET FEATURES [Disable ECC] [OBS-4]";
450  case 0x89:
451  return "SET FEATURES [Reserved (address offset)]";
452  case 0x8A:
453  return "SET FEATURES [Disable CFA power mode 1]";
454  case 0x90:
455  return "SET FEATURES [Disable SATA feature]"; // ACS-3
456  case 0x95:
457  return "SET FEATURES [Enable Media Status Notf] [OBS-8]";
458  case 0x99:
459  return "SET FEATURES [Enable retries] [OBS-4]";
460  case 0x9A:
461  return "SET FEATURES [Set max avg curr] [OBS-4]";
462  case 0xAA:
463  return "SET FEATURES [Enable read look-ahead]";
464  case 0xAB:
465  return "SET FEATURES [Set max prefetch] [OBS-4]";
466  case 0xBB:
467  return "SET FEATURES [4 bytes VS data] [OBS-4]";
468  case 0xC1:
469  return "SET FEATURES [Disable Free-fall Control]"; // ATA-8
470  case 0xC2:
471  return "SET FEATURES [Disable AAM] [OBS-ACS-2]";
472  case 0xC3:
473  return "SET FEATURES [Sense Data Reporting]"; // ACS-2
474  case 0xCC:
475  return "SET FEATURES [Enable revert to defaults]";
476  case 0xDD:
477  return "SET FEATURES [Disable release interrupt] [OBS-ACS-2]";
478  case 0xDE:
479  return "SET FEATURES [Disable SERVICE interrupt] [OBS-ACS-2]";
480  case 0xE0:
481  return "SET FEATURES [Vendor specific] [OBS-7]";
482  default:
483  if (f_reg >= 0xF0)
484  return "SET FEATURES [Reserved for CFA]";
485  else
486  return "SET FEATURES [Reserved subcommand]";
487  }
488  case 0xF9: /* SET MAX */
489  switch (f_reg) {
490  case 0x00:
491  return "SET MAX ADDRESS [OBS-6]";
492  case 0x01:
493  return "SET MAX SET PASSWORD [OBS-ACS-3]";
494  case 0x02:
495  return "SET MAX LOCK [OBS-ACS-3]";
496  case 0x03:
497  return "SET MAX UNLOCK [OBS-ACS-3]";
498  case 0x04:
499  return "SET MAX FREEZE LOCK [OBS-ACS-3]";
500  default:
501  return "SET MAX [Reserved subcommand] [OBS-ACS-3]";
502  }
503  default:
504  return command_table[c_code];
505  }
506 }
const char cmd_reserved[]
Definition: atacmdnames.cpp:19
const char cmd_vendor_specific[]
Definition: atacmdnames.cpp:20
const char cmd_reserved_mcpt[]
Definition: atacmdnames.cpp:23
#define ATACMDNAMES_H_CVSID
Definition: atacmdnames.h:17
const char cmd_reserved_sa[]
Definition: atacmdnames.cpp:21
char ASSERT_command_table_size[sizeof(command_table)/sizeof(command_table[0])==256?1:-1]
const char cmd_reserved_cf[]
Definition: atacmdnames.cpp:22
const char *const command_table[]
Definition: atacmdnames.cpp:29
const char * atacmdnames_cpp_cvsid
Definition: atacmdnames.cpp:16
const char cmd_seek_ret4[]
Definition: atacmdnames.cpp:25
const char cmd_recalibrate_ret4[]
Definition: atacmdnames.cpp:24
const char * look_up_ata_command(unsigned char c_code, unsigned char f_reg)