smartmontools SVN Rev 3317
Utility to control and monitor storage systems with "S.M.A.R.T."
atacmdnames.cpp
Go to the documentation of this file.
00001 /*
00002  * atacmdnames.cpp
00003  *
00004  * Home page of code is: http://smartmontools.sourceforge.net
00005  *
00006  * Copyright (C) 2003-8 Philip Williams
00007  * Copyright (C) 2012 Christian Franke <smartmontools-support@lists.sourceforge.net>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2, or (at your option)
00012  * any later version.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  */
00018 
00019 #include "atacmdnames.h"
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 
00023 const char * atacmdnames_cpp_cvsid = "$Id: atacmdnames.cpp 3670 2012-10-31 22:00:50Z chrfranke $"
00024   ATACMDNAMES_H_CVSID;
00025 
00026 const char cmd_reserved[]        = "[RESERVED]";
00027 const char cmd_vendor_specific[] = "[VENDOR SPECIFIC]";
00028 const char cmd_reserved_sa[]     = "[RESERVED FOR SERIAL ATA]";
00029 const char cmd_reserved_cf[]     = "[RESERVED FOR COMPACTFLASH ASSOCIATION]";
00030 const char cmd_reserved_mcpt[]   = "[RESERVED FOR MEDIA CARD PASS THROUGH]"; // ACS-3: Reserved
00031 const char cmd_recalibrate_ret4[]= "RECALIBRATE [RET-4]";
00032 const char cmd_seek_ret4[]       = "SEEK [RET-4]";
00033 
00034 // Tables B.3 and B.4 of T13/2161-D (ACS-3) Revision 4, September 4, 2012
00035 
00036 const char * const command_table[] = {
00037 /*-------------------------------------------------- 00h-0Fh -----*/
00038   "NOP",
00039   cmd_reserved,
00040   cmd_reserved,
00041   "CFA REQUEST EXTENDED ERROR",
00042   cmd_reserved,
00043   cmd_reserved,
00044   "DATA SET MANAGEMENT", // ACS-2
00045   cmd_reserved,
00046   "DEVICE RESET",
00047   cmd_reserved,
00048   cmd_reserved,
00049   "REQUEST SENSE DATA EXT", // ACS-2
00050   cmd_reserved,
00051   cmd_reserved,
00052   cmd_reserved,
00053   cmd_reserved,
00054 /*-------------------------------------------------- 10h-1Fh -----*/
00055   "RECALIBRATE [OBS-4]",
00056   cmd_recalibrate_ret4,
00057   cmd_recalibrate_ret4,
00058   cmd_recalibrate_ret4,
00059   cmd_recalibrate_ret4,
00060   cmd_recalibrate_ret4,
00061   cmd_recalibrate_ret4,
00062   cmd_recalibrate_ret4,
00063   cmd_recalibrate_ret4,
00064   cmd_recalibrate_ret4,
00065   cmd_recalibrate_ret4,
00066   cmd_recalibrate_ret4,
00067   cmd_recalibrate_ret4,
00068   cmd_recalibrate_ret4,
00069   cmd_recalibrate_ret4,
00070   cmd_recalibrate_ret4,
00071 /*-------------------------------------------------- 20h-2Fh -----*/
00072   "READ SECTOR(S)",
00073   "READ SECTOR(S) [OBS-5]",
00074   "READ LONG [OBS-4]",
00075   "READ LONG (w/o retry) [OBS-4]",
00076   "READ SECTOR(S) EXT",
00077   "READ DMA EXT",
00078   "READ DMA QUEUED EXT [OBS-ACS-2]",
00079   "READ NATIVE MAX ADDRESS EXT [OBS-ACS-3]",
00080   cmd_reserved,
00081   "READ MULTIPLE EXT",
00082   "READ STREAM DMA",
00083   "READ STREAM",
00084   cmd_reserved,
00085   cmd_reserved,
00086   cmd_reserved,
00087   "READ LOG EXT",
00088 /*-------------------------------------------------- 30h-3Fh -----*/
00089   "WRITE SECTOR(S)",
00090   "WRITE SECTOR(S) (w/o retry) [OBS-5]",
00091   "WRITE LONG [OBS-4]",
00092   "WRITE LONG (w/o retry) [OBS-4]",
00093   "WRITE SECTORS(S) EXT",
00094   "WRITE DMA EXT",
00095   "WRITE DMA QUEUED EXT [OBS-ACS-2]",
00096   "SET NATIVE MAX ADDRESS EXT [OBS-ACS-3]",
00097   "CFA WRITE SECTORS WITHOUT ERASE",
00098   "WRITE MULTIPLE EXT",
00099   "WRITE STREAM DMA",
00100   "WRITE STREAM",
00101   "WRITE VERIFY [OBS-4]",
00102   "WRITE DMA FUA EXT",
00103   "WRITE DMA QUEUED FUA EXT [OBS-ACS-2]",
00104   "WRITE LOG EXT",
00105 /*-------------------------------------------------- 40h-4Fh -----*/
00106   "READ VERIFY SECTOR(S)",
00107   "READ VERIFY SECTOR(S) (w/o retry) [OBS-5]",
00108   "READ VERIFY SECTOR(S) EXT",
00109   cmd_reserved,
00110   cmd_reserved,
00111   "WRITE UNCORRECTABLE EXT", // ATA-8
00112   cmd_reserved,
00113   "READ LOG DMA EXT", // ATA-8
00114   cmd_reserved,
00115   cmd_reserved,
00116   cmd_reserved,
00117   cmd_reserved,
00118   cmd_reserved,
00119   cmd_reserved,
00120   cmd_reserved,
00121   cmd_reserved,
00122 /*-------------------------------------------------- 50h-5Fh -----*/
00123   "FORMAT TRACK [OBS-4]",
00124   "CONFIGURE STREAM",
00125   cmd_reserved,
00126   cmd_reserved,
00127   cmd_reserved,
00128   cmd_reserved,
00129   cmd_reserved,
00130   "WRITE LOG DMA EXT", // ATA-8
00131   cmd_reserved,
00132   cmd_reserved,
00133   cmd_reserved,
00134   "TRUSTED NON-DATA", // ATA-8
00135   "TRUSTED RECEIVE", // ATA-8
00136   "TRUSTED RECEIVE DMA", // ATA-8
00137   "TRUSTED SEND", // ATA-8
00138   "TRUSTED SEND DMA", // ATA-8
00139 /*-------------------------------------------------- 60h-6Fh -----*/
00140   "READ FPDMA QUEUED", // ATA-8
00141   "WRITE FPDMA QUEUED", // ATA-8
00142   cmd_reserved_sa,
00143   "NCQ QUEUE MANAGEMENT", // ACS-3
00144   "SEND FPDMA QUEUED", // ACS-3
00145   "RECEIVE FPDMA QUEUED", // ACS-3
00146   cmd_reserved_sa,
00147   cmd_reserved_sa,
00148   cmd_reserved,
00149   cmd_reserved,
00150   cmd_reserved,
00151   cmd_reserved,
00152   cmd_reserved,
00153   cmd_reserved,
00154   cmd_reserved,
00155   cmd_reserved,
00156 /*-------------------------------------------------- 70h-7Fh -----*/
00157   "SEEK [OBS-7]",
00158   cmd_seek_ret4,
00159   cmd_seek_ret4,
00160   cmd_seek_ret4,
00161   cmd_seek_ret4,
00162   cmd_seek_ret4,
00163   cmd_seek_ret4,
00164   "SET DATE & TIME EXT", // ACS-3
00165   "ACCESSIBLE MAX ADDRESS CONFIGURATION", // ACS-3
00166   cmd_seek_ret4,
00167   cmd_seek_ret4,
00168   cmd_seek_ret4,
00169   cmd_seek_ret4,
00170   cmd_seek_ret4,
00171   cmd_seek_ret4,
00172   cmd_seek_ret4,
00173 /*-------------------------------------------------- 80h-8Fh -----*/
00174   cmd_vendor_specific,
00175   cmd_vendor_specific,
00176   cmd_vendor_specific,
00177   cmd_vendor_specific,
00178   cmd_vendor_specific,
00179   cmd_vendor_specific,
00180   cmd_vendor_specific,
00181   "CFA TRANSLATE SECTOR [VS IF NO CFA]",
00182   cmd_vendor_specific,
00183   cmd_vendor_specific,
00184   cmd_vendor_specific,
00185   cmd_vendor_specific,
00186   cmd_vendor_specific,
00187   cmd_vendor_specific,
00188   cmd_vendor_specific,
00189   cmd_vendor_specific,
00190 /*-------------------------------------------------- 90h-9Fh -----*/
00191   "EXECUTE DEVICE DIAGNOSTIC",
00192   "INITIALIZE DEVICE PARAMETERS [OBS-6]",
00193   "DOWNLOAD MICROCODE",
00194   "DOWNLOAD MICROCODE DMA", // ACS-2
00195   "STANDBY IMMEDIATE [RET-4]",
00196   "IDLE IMMEDIATE [RET-4]",
00197   "STANDBY [RET-4]",
00198   "IDLE [RET-4]",
00199   "CHECK POWER MODE [RET-4]",
00200   "SLEEP [RET-4]",
00201   cmd_vendor_specific,
00202   cmd_reserved,
00203   cmd_reserved,
00204   cmd_reserved,
00205   cmd_reserved,
00206   cmd_reserved,
00207 /*-------------------------------------------------- A0h-AFh -----*/
00208   "PACKET",
00209   "IDENTIFY PACKET DEVICE",
00210   "SERVICE [OBS-ACS-2]",
00211   cmd_reserved,
00212   cmd_reserved,
00213   cmd_reserved,
00214   cmd_reserved,
00215   cmd_reserved,
00216   cmd_reserved,
00217   cmd_reserved,
00218   cmd_reserved,
00219   cmd_reserved,
00220   cmd_reserved,
00221   cmd_reserved,
00222   cmd_reserved,
00223   cmd_reserved,
00224 /*-------------------------------------------------- B0h-BFh -----*/
00225   "SMART",
00226   "DEVICE CONFIGURATION [OBS-ACS-3]",
00227   cmd_reserved,
00228   cmd_reserved,
00229   "SANITIZE DEVICE", // ACS-2
00230   cmd_reserved,
00231   "NV CACHE [OBS-ACS-3]", // ATA-8
00232   cmd_reserved_cf,
00233   cmd_reserved_cf,
00234   cmd_reserved_cf,
00235   cmd_reserved_cf,
00236   cmd_reserved_cf,
00237   cmd_reserved,
00238   cmd_reserved,
00239   cmd_reserved,
00240   cmd_reserved,
00241 /*-------------------------------------------------- C0h-CFh -----*/
00242   "CFA ERASE SECTORS [VS IF NO CFA]",
00243   cmd_vendor_specific,
00244   cmd_vendor_specific,
00245   cmd_vendor_specific,
00246   "READ MULTIPLE",
00247   "WRITE MULTIPLE",
00248   "SET MULTIPLE MODE",
00249   "READ DMA QUEUED [OBS-ACS-2]",
00250   "READ DMA",
00251   "READ DMA (w/o retry) [OBS-5]",
00252   "WRITE DMA",
00253   "WRITE DMA (w/o retry) [OBS-5]",
00254   "WRITE DMA QUEUED [OBS-ACS-2]",
00255   "CFA WRITE MULTIPLE WITHOUT ERASE",
00256   "WRITE MULTIPLE FUA EXT",
00257   cmd_reserved,
00258 /*-------------------------------------------------- D0h-DFh -----*/
00259   cmd_reserved,
00260   "CHECK MEDIA CARD TYPE [OBS-ACS-2]",
00261   cmd_reserved_mcpt,
00262   cmd_reserved_mcpt,
00263   cmd_reserved_mcpt,
00264   cmd_reserved,
00265   cmd_reserved,
00266   cmd_reserved,
00267   cmd_reserved,
00268   cmd_reserved,
00269   "GET MEDIA STATUS [OBS-8]",
00270   "ACKNOWLEDGE MEDIA CHANGE [RET-4]",
00271   "BOOT POST-BOOT [RET-4]",
00272   "BOOT PRE-BOOT [RET-4]",
00273   "MEDIA LOCK [OBS-8]",
00274   "MEDIA UNLOCK [OBS-8]",
00275 /*-------------------------------------------------- E0h-EFh -----*/
00276   "STANDBY IMMEDIATE",
00277   "IDLE IMMEDIATE",
00278   "STANDBY",
00279   "IDLE",
00280   "READ BUFFER",
00281   "CHECK POWER MODE",
00282   "SLEEP",
00283   "FLUSH CACHE",
00284   "WRITE BUFFER",
00285   "READ BUFFER DMA", // ACS-2 (was: WRITE SAME [RET-4])
00286   "FLUSH CACHE EXT",
00287   "WRITE BUFFER DMA", // ACS-2
00288   "IDENTIFY DEVICE",
00289   "MEDIA EJECT [OBS-8]",
00290   "IDENTIFY DEVICE DMA [OBS-4]",
00291   "SET FEATURES",
00292 /*-------------------------------------------------- F0h-FFh -----*/
00293   cmd_vendor_specific,
00294   "SECURITY SET PASSWORD",
00295   "SECURITY UNLOCK",
00296   "SECURITY ERASE PREPARE",
00297   "SECURITY ERASE UNIT",
00298   "SECURITY FREEZE LOCK",
00299   "SECURITY DISABLE PASSWORD",
00300   cmd_vendor_specific,
00301   "READ NATIVE MAX ADDRESS [OBS-ACS-3]",
00302   "SET MAX ADDRESS [OBS-ACS-3]",
00303   cmd_vendor_specific,
00304   cmd_vendor_specific,
00305   cmd_vendor_specific,
00306   cmd_vendor_specific,
00307   cmd_vendor_specific,
00308   cmd_vendor_specific
00309 };
00310 
00311 typedef char ASSERT_command_table_size[
00312   sizeof(command_table)/sizeof(command_table[0]) == 256 ? 1 : -1];
00313 
00314 /* Returns the name of the command (and possibly sub-command) with the given
00315    command code and feature register values.   For most command codes this
00316    simply returns the corresponding entry in the command_table array, but for
00317    others the value of the feature register specifies a subcommand or
00318    distinguishes commands. */
00319 const char *look_up_ata_command(unsigned char c_code, unsigned char f_reg) {
00320 
00321   switch (c_code) {
00322   case 0x00:  /* NOP */
00323     switch (f_reg) {
00324     case 0x00:
00325       return "NOP [Abort queued commands]";
00326     case 0x01:
00327       return "NOP [Don't abort queued commands] [OBS-ACS-2]";
00328     default:
00329       return "NOP [Reserved subcommand] [OBS-ACS-2]";
00330     }
00331   case 0x92:  /* DOWNLOAD MICROCODE */
00332     switch (f_reg) {
00333     case 0x01:
00334       return "DOWNLOAD MICROCODE [Temporary] [OBS-8]";
00335     case 0x03:
00336       return "DOWNLOAD MICROCODE [Save with offsets]"; // ATA-8
00337     case 0x07:
00338       return "DOWNLOAD MICROCODE [Save]";
00339     case 0x0e:
00340       return "DOWNLOAD MICROCODE [Save for future use]"; // ACS-3
00341     case 0x0f:
00342       return "DOWNLOAD MICROCODE [Activate]"; // ACS-3
00343     default:
00344       return "DOWNLOAD MICROCODE [Reserved subcommand]";
00345     }
00346   case 0xB0:  /* SMART */
00347     switch (f_reg) {
00348     case 0xD0:
00349       return "SMART READ DATA";
00350     case 0xD1:
00351       return "SMART READ ATTRIBUTE THRESHOLDS [OBS-4]";
00352     case 0xD2:
00353       return "SMART ENABLE/DISABLE ATTRIBUTE AUTOSAVE";
00354     case 0xD3:
00355       return "SMART SAVE ATTRIBUTE VALUES [OBS-6]";
00356     case 0xD4:
00357       return "SMART EXECUTE OFF-LINE IMMEDIATE";
00358     case 0xD5:
00359       return "SMART READ LOG";
00360     case 0xD6:
00361       return "SMART WRITE LOG";
00362     case 0xD7:
00363       return "SMART WRITE ATTRIBUTE THRESHOLDS [NS, OBS-4]";
00364     case 0xD8:
00365       return "SMART ENABLE OPERATIONS";
00366     case 0xD9:
00367       return "SMART DISABLE OPERATIONS";
00368     case 0xDA:
00369       return "SMART RETURN STATUS";
00370     case 0xDB:
00371       return "SMART EN/DISABLE AUTO OFFLINE [NS (SFF-8035i)]";
00372     default:
00373         if (f_reg >= 0xE0)
00374           return "SMART [Vendor specific subcommand]";
00375         else
00376           return "SMART [Reserved subcommand]";
00377     }
00378   case 0xB1:  /* DEVICE CONFIGURATION */
00379     switch (f_reg) {
00380     case 0xC0:
00381       return "DEVICE CONFIGURATION RESTORE [OBS-ACS-3]";
00382     case 0xC1:
00383       return "DEVICE CONFIGURATION FREEZE LOCK [OBS-ACS-3]";
00384     case 0xC2:
00385       return "DEVICE CONFIGURATION IDENTIFY [OBS-ACS-3]";
00386     case 0xC3:
00387       return "DEVICE CONFIGURATION SET [OBS-ACS-3]";
00388     default:
00389       return "DEVICE CONFIGURATION [Reserved subcommand] [OBS-ACS-3]";
00390     }
00391   case 0xEF:  /* SET FEATURES */
00392     switch (f_reg) {
00393     case 0x01:
00394       return "SET FEATURES [Enable 8-bit PIO] [OBS-3]"; // Now CFA
00395     case 0x02:
00396       return "SET FEATURES [Enable write cache]";
00397     case 0x03:
00398       return "SET FEATURES [Set transfer mode]";
00399     case 0x04:
00400       return "SET FEATURES [Enable auto DR] [OBS-4]";
00401     case 0x05:
00402       return "SET FEATURES [Enable APM]";
00403     case 0x06:
00404       return "SET FEATURES [Enable Pwr-Up In Standby]";
00405     case 0x07:
00406       return "SET FEATURES [Set device spin-up]";
00407     case 0x09:
00408       return "SET FEATURES [Reserved (address offset)] [OPS-ACS-3]";
00409     case 0x0A:
00410       return "SET FEATURES [Enable CFA power mode 1]";
00411     case 0x10:
00412       return "SET FEATURES [Enable SATA feature]"; // ACS-3
00413     case 0x20:
00414       return "SET FEATURES [Set Time-ltd R/W WCT]";
00415     case 0x21:
00416       return "SET FEATURES [Set Time-ltd R/W EH]";
00417     case 0x31:
00418       return "SET FEATURES [Disable Media Status Notf] [OBS-8]";
00419     case 0x33:
00420       return "SET FEATURES [Disable retry] [OBS-4]";
00421     case 0x41:
00422       return "SET FEATURES [Enable Free-fall Control]"; // ATA-8
00423     case 0x42:
00424       return "SET FEATURES [Enable AAM] [OBS-ACS-2]";
00425     case 0x43:
00426       return "SET FEATURES [Set Max Host I/F S Times]";
00427     case 0x44:
00428       return "SET FEATURES [Length of VS data] [OBS-4]";
00429     case 0x4a:
00430       return "SET FEATURES [Ext. Power Conditions]"; // ACS-2
00431     case 0x54:
00432       return "SET FEATURES [Set cache segs] [OBS-4]";
00433     case 0x55:
00434       return "SET FEATURES [Disable read look-ahead]";
00435     case 0x5D:
00436       return "SET FEATURES [Enable release interrupt] [OBS-ACS-2]";
00437     case 0x5E:
00438       return "SET FEATURES [Enable SERVICE interrupt] [OBS-ACS-2]";
00439     case 0x66:
00440       return "SET FEATURES [Disable revert defaults]";
00441     case 0x69:
00442       return "SET FEATURES [LPS Error Reporting Control]"; // ACS-2
00443     case 0x77:
00444       return "SET FEATURES [Disable ECC] [OBS-4]";
00445     case 0x81:
00446       return "SET FEATURES [Disable 8-bit PIO] [OBS-3]"; // Now CFA
00447     case 0x82:
00448       return "SET FEATURES [Disable write cache]";
00449     case 0x84:
00450       return "SET FEATURES [Disable auto DR] [OBS-4]";
00451     case 0x85:
00452       return "SET FEATURES [Disable APM]";
00453     case 0x86:
00454       return "SET FEATURES [Disable Pwr-Up In Standby]";
00455     case 0x88:
00456       return "SET FEATURES [Disable ECC] [OBS-4]";
00457     case 0x89:
00458       return "SET FEATURES [Reserved (address offset)]";
00459     case 0x8A:
00460       return "SET FEATURES [Disable CFA power mode 1]";
00461     case 0x90:
00462       return "SET FEATURES [Disable SATA feature]"; // ACS-3
00463     case 0x95:
00464       return "SET FEATURES [Enable Media Status Notf] [OBS-8]";
00465     case 0x99:
00466       return "SET FEATURES [Enable retries] [OBS-4]";
00467     case 0x9A:
00468       return "SET FEATURES [Set max avg curr] [OBS-4]";
00469     case 0xAA:
00470       return "SET FEATURES [Enable read look-ahead]";
00471     case 0xAB:
00472       return "SET FEATURES [Set max prefetch] [OBS-4]";
00473     case 0xBB:
00474       return "SET FEATURES [4 bytes VS data] [OBS-4]";
00475     case 0xC1:
00476       return "SET FEATURES [Disable Free-fall Control]"; // ATA-8
00477     case 0xC2:
00478       return "SET FEATURES [Disable AAM] [OBS-ACS-2]";
00479     case 0xC3:
00480       return "SET FEATURES [Sense Data Reporting]"; // ACS-2
00481     case 0xCC:
00482       return "SET FEATURES [Enable revert to defaults]";
00483     case 0xDD:
00484       return "SET FEATURES [Disable release interrupt] [OBS-ACS-2]";
00485     case 0xDE:
00486       return "SET FEATURES [Disable SERVICE interrupt] [OBS-ACS-2]";
00487     case 0xE0:
00488       return "SET FEATURES [Vendor specific] [OBS-7]";
00489     default:
00490       if (f_reg >= 0xF0)
00491         return "SET FEATURES [Reserved for CFA]";
00492       else
00493         return "SET FEATURES [Reserved subcommand]";
00494     }
00495   case 0xF9:  /* SET MAX */
00496     switch (f_reg) {
00497     case 0x00:
00498       return "SET MAX ADDRESS [OBS-6]";
00499     case 0x01:
00500       return "SET MAX SET PASSWORD [OBS-ACS-3]";
00501     case 0x02:
00502       return "SET MAX LOCK [OBS-ACS-3]";
00503     case 0x03:
00504       return "SET MAX UNLOCK [OBS-ACS-3]";
00505     case 0x04:
00506       return "SET MAX FREEZE LOCK [OBS-ACS-3]";
00507     default:
00508       return "SET MAX [Reserved subcommand] [OBS-ACS-3]";
00509     }
00510   default:
00511     return command_table[c_code];
00512   }
00513 }