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