Annotation of embedaddon/smartmontools/atacmdnames.cpp, revision 1.1
1.1 ! misho 1: /*
! 2: * atacmdnames.cpp
! 3: *
! 4: * This module is based on the T13/1532D Volume 1 Revision 3 (ATA/ATAPI-7)
! 5: * specification, which is available from http://www.t13.org/#FTP_site
! 6: *
! 7: * Home page of code is: http://smartmontools.sourceforge.net
! 8: * Address of support mailing list: smartmontools-support@lists.sourceforge.net
! 9: *
! 10: * Copyright (C) 2003-8 Philip Williams
! 11: *
! 12: * This program is free software; you can redistribute it and/or modify
! 13: * it under the terms of the GNU General Public License as published by
! 14: * the Free Software Foundation; either version 2, or (at your option)
! 15: * any later version.
! 16: *
! 17: * You should have received a copy of the GNU General Public License
! 18: * (for example COPYING); if not, write to the Free
! 19: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
! 20: *
! 21: */
! 22:
! 23: #include "atacmdnames.h"
! 24: #include <stdlib.h>
! 25: #include <stdio.h>
! 26:
! 27: #define COMMAND_TABLE_SIZE 256
! 28:
! 29: const char *atacmdnames_c_cvsid="$Id: atacmdnames.cpp,v 1.17 2008/03/29 23:41:28 shattered Exp $" ATACMDNAMES_H_CVSID;
! 30:
! 31: const char cmd_reserved[] = "[RESERVED]";
! 32: const char cmd_vendor_specific[] = "[VENDOR SPECIFIC]";
! 33: const char cmd_reserved_sa[] = "[RESERVED FOR SERIAL ATA]";
! 34: const char cmd_reserved_cf[] = "[RESERVED FOR COMPACTFLASH ASSOCIATION]";
! 35: const char cmd_reserved_mcpt[] = "[RESERVED FOR MEDIA CARD PASS THROUGH]";
! 36: const char cmd_recalibrate_ret4[]= "RECALIBRATE [RET-4]";
! 37: const char cmd_seek_ret4[] = "SEEK [RET-4]";
! 38:
! 39: const char *command_table[COMMAND_TABLE_SIZE] = {
! 40: /*-------------------------------------------------- 00h-0Fh -----*/
! 41: "NOP",
! 42: cmd_reserved,
! 43: cmd_reserved,
! 44: "CFA REQUEST EXTENDED ERROR CODE",
! 45: cmd_reserved,
! 46: cmd_reserved,
! 47: cmd_reserved,
! 48: cmd_reserved,
! 49: "DEVICE RESET",
! 50: cmd_reserved,
! 51: cmd_reserved,
! 52: cmd_reserved,
! 53: cmd_reserved,
! 54: cmd_reserved,
! 55: cmd_reserved,
! 56: cmd_reserved,
! 57: /*-------------------------------------------------- 10h-1Fh -----*/
! 58: "RECALIBRATE [OBS-4]",
! 59: cmd_recalibrate_ret4,
! 60: cmd_recalibrate_ret4,
! 61: cmd_recalibrate_ret4,
! 62: cmd_recalibrate_ret4,
! 63: cmd_recalibrate_ret4,
! 64: cmd_recalibrate_ret4,
! 65: cmd_recalibrate_ret4,
! 66: cmd_recalibrate_ret4,
! 67: cmd_recalibrate_ret4,
! 68: cmd_recalibrate_ret4,
! 69: cmd_recalibrate_ret4,
! 70: cmd_recalibrate_ret4,
! 71: cmd_recalibrate_ret4,
! 72: cmd_recalibrate_ret4,
! 73: cmd_recalibrate_ret4,
! 74: /*-------------------------------------------------- 20h-2Fh -----*/
! 75: "READ SECTOR(S)",
! 76: "READ SECTOR(S) [OBS-5]",
! 77: "READ LONG (w/ retry) [OBS-4]",
! 78: "READ LONG (w/o retry) [OBS-4]",
! 79: "READ SECTOR(S) EXT",
! 80: "READ DMA EXT",
! 81: "READ DMA QUEUED EXT",
! 82: "READ NATIVE MAX ADDRESS EXT",
! 83: cmd_reserved,
! 84: "READ MULTIPLE EXT",
! 85: "READ STREAM DMA",
! 86: "READ STREAM PIO",
! 87: cmd_reserved,
! 88: cmd_reserved,
! 89: cmd_reserved,
! 90: "READ LOG EXT",
! 91: /*-------------------------------------------------- 30h-3Fh -----*/
! 92: "WRITE SECTOR(S)",
! 93: "WRITE SECTOR(S) [OBS-5]",
! 94: "WRITE LONG(w/ retry) [OBS-4]",
! 95: "WRITE LONG(w/o retry) [OBS-4]",
! 96: "WRITE SECTORS(S) EXT",
! 97: "WRITE DMA EXT",
! 98: "WRITE DMA QUEUED EXT",
! 99: "SET MAX ADDRESS EXT",
! 100: "CFA WRITE SECTORS WITHOUT ERASE",
! 101: "WRITE MULTIPLE EXT",
! 102: "WRITE STREAM DMA",
! 103: "WRITE STREAM PIO",
! 104: "WRITE VERIFY [OBS-4]",
! 105: "WRITE DMA FUA EXT",
! 106: "WRITE DMA QUEUED FUA EXT",
! 107: "WRITE LOG EXT",
! 108: /*-------------------------------------------------- 40h-4Fh -----*/
! 109: "READ VERIFY SECTOR(S)",
! 110: "READ VERIFY SECTOR(S) [OBS-5]",
! 111: "READ VERIFY SECTOR(S) EXT",
! 112: cmd_reserved,
! 113: cmd_reserved,
! 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: cmd_reserved,
! 123: cmd_reserved,
! 124: cmd_reserved,
! 125: /*-------------------------------------------------- 50h-5Fh -----*/
! 126: "FORMAT TRACK [OBS-4]",
! 127: "CONFIGURE STREAM",
! 128: cmd_reserved,
! 129: cmd_reserved,
! 130: cmd_reserved,
! 131: cmd_reserved,
! 132: cmd_reserved,
! 133: cmd_reserved,
! 134: cmd_reserved,
! 135: cmd_reserved,
! 136: cmd_reserved,
! 137: cmd_reserved,
! 138: cmd_reserved,
! 139: cmd_reserved,
! 140: cmd_reserved,
! 141: cmd_reserved,
! 142: /*-------------------------------------------------- 60h-6Fh -----*/
! 143: "READ FPDMA QUEUED",
! 144: "WRITE FPDMA QUEUED",
! 145: cmd_reserved_sa,
! 146: cmd_reserved_sa,
! 147: cmd_reserved_sa,
! 148: cmd_reserved_sa,
! 149: cmd_reserved_sa,
! 150: cmd_reserved_sa,
! 151: cmd_reserved,
! 152: cmd_reserved,
! 153: cmd_reserved,
! 154: cmd_reserved,
! 155: cmd_reserved,
! 156: cmd_reserved,
! 157: cmd_reserved,
! 158: cmd_reserved,
! 159: /*-------------------------------------------------- 70h-7Fh -----*/
! 160: "SEEK [OBS-7]",
! 161: cmd_seek_ret4,
! 162: cmd_seek_ret4,
! 163: cmd_seek_ret4,
! 164: cmd_seek_ret4,
! 165: cmd_seek_ret4,
! 166: cmd_seek_ret4,
! 167: cmd_seek_ret4,
! 168: cmd_seek_ret4,
! 169: cmd_seek_ret4,
! 170: cmd_seek_ret4,
! 171: cmd_seek_ret4,
! 172: cmd_seek_ret4,
! 173: cmd_seek_ret4,
! 174: cmd_seek_ret4,
! 175: cmd_seek_ret4,
! 176: /*-------------------------------------------------- 80h-8Fh -----*/
! 177: cmd_vendor_specific,
! 178: cmd_vendor_specific,
! 179: cmd_vendor_specific,
! 180: cmd_vendor_specific,
! 181: cmd_vendor_specific,
! 182: cmd_vendor_specific,
! 183: cmd_vendor_specific,
! 184: "CFA TRANSLATE SECTOR [VS IF NO CFA]",
! 185: cmd_vendor_specific,
! 186: cmd_vendor_specific,
! 187: cmd_vendor_specific,
! 188: cmd_vendor_specific,
! 189: cmd_vendor_specific,
! 190: cmd_vendor_specific,
! 191: cmd_vendor_specific,
! 192: cmd_vendor_specific,
! 193: /*-------------------------------------------------- 90h-9Fh -----*/
! 194: "EXECUTE DEVICE DIAGNOSTIC",
! 195: "INITIALIZE DEVICE PARAMETERS [OBS-6]",
! 196: "DOWNLOAD MICROCODE",
! 197: cmd_reserved,
! 198: "STANDBY IMMEDIATE [RET-4]",
! 199: "IDLE IMMEDIATE [RET-4]",
! 200: "STANDBY [RET-4]",
! 201: "IDLE [RET-4]",
! 202: "CHECK POWER MODE [RET-4]",
! 203: "SLEEP [RET-4]",
! 204: cmd_vendor_specific,
! 205: cmd_reserved,
! 206: cmd_reserved,
! 207: cmd_reserved,
! 208: cmd_reserved,
! 209: cmd_reserved,
! 210: /*-------------------------------------------------- A0h-AFh -----*/
! 211: "PACKET",
! 212: "IDENTIFY PACKET DEVICE",
! 213: "SERVICE",
! 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: cmd_reserved,
! 225: cmd_reserved,
! 226: cmd_reserved,
! 227: /*-------------------------------------------------- B0h-BFh -----*/
! 228: "SMART",
! 229: "DEVICE CONFIGURATION",
! 230: cmd_reserved,
! 231: cmd_reserved,
! 232: cmd_reserved,
! 233: cmd_reserved,
! 234: cmd_reserved,
! 235: cmd_reserved,
! 236: cmd_reserved_cf,
! 237: cmd_reserved_cf,
! 238: cmd_reserved_cf,
! 239: cmd_reserved_cf,
! 240: cmd_reserved_cf,
! 241: cmd_reserved_cf,
! 242: cmd_reserved_cf,
! 243: cmd_reserved_cf,
! 244: /*-------------------------------------------------- C0h-CFh -----*/
! 245: "CFA ERASE SECTORS [VS IF NO CFA]",
! 246: cmd_vendor_specific,
! 247: cmd_vendor_specific,
! 248: cmd_vendor_specific,
! 249: "READ MULTIPLE",
! 250: "WRITE MULTIPLE",
! 251: "SET MULTIPLE MODE",
! 252: "READ DMA QUEUED",
! 253: "READ DMA",
! 254: "READ DMA [OBS-5]",
! 255: "WRITE DMA",
! 256: "WRITE DMA [OBS-5]",
! 257: "WRITE DMA QUEUED",
! 258: "CFA WRITE MULTIPLE WITHOUT ERASE",
! 259: "WRITE MULTIPLE FUA EXT",
! 260: cmd_reserved,
! 261: /*-------------------------------------------------- D0h-DFh -----*/
! 262: cmd_reserved,
! 263: "CHECK MEDIA CARD TYPE",
! 264: cmd_reserved_mcpt,
! 265: cmd_reserved_mcpt,
! 266: cmd_reserved_mcpt,
! 267: cmd_reserved,
! 268: cmd_reserved,
! 269: cmd_reserved,
! 270: cmd_reserved,
! 271: cmd_reserved,
! 272: "GET MEDIA STATUS",
! 273: "ACKNOWLEDGE MEDIA CHANGE [RET-4]",
! 274: "BOOT POST-BOOT [RET-4]",
! 275: "BOOT PRE-BOOT [RET-4]",
! 276: "MEDIA LOCK",
! 277: "MEDIA UNLOCK",
! 278: /*-------------------------------------------------- E0h-EFh -----*/
! 279: "STANDBY IMMEDIATE",
! 280: "IDLE IMMEDIATE",
! 281: "STANDBY",
! 282: "IDLE",
! 283: "READ BUFFER",
! 284: "CHECK POWER MODE",
! 285: "SLEEP",
! 286: "FLUSH CACHE",
! 287: "WRITE BUFFER",
! 288: "WRITE SAME [RET-4]", /* Warning! This command is retired but the value of
! 289: f_reg is used in look_up_ata_command(). If this
! 290: command code is reclaimed in a future standard then
! 291: be sure to update look_up_ata_command(). */
! 292: "FLUSH CACHE EXT",
! 293: cmd_reserved,
! 294: "IDENTIFY DEVICE",
! 295: "MEDIA EJECT",
! 296: "IDENTIFY DEVICE DMA [OBS-4]",
! 297: "SET FEATURES",
! 298: /*-------------------------------------------------- F0h-FFh -----*/
! 299: cmd_vendor_specific,
! 300: "SECURITY SET PASSWORD",
! 301: "SECURITY UNLOCK",
! 302: "SECURITY ERASE PREPARE",
! 303: "SECURITY ERASE UNIT",
! 304: "SECURITY FREEZE LOCK",
! 305: "SECURITY DISABLE PASSWORD",
! 306: cmd_vendor_specific,
! 307: "READ NATIVE MAX ADDRESS",
! 308: "SET MAX",
! 309: cmd_vendor_specific,
! 310: cmd_vendor_specific,
! 311: cmd_vendor_specific,
! 312: cmd_vendor_specific,
! 313: cmd_vendor_specific,
! 314: cmd_vendor_specific
! 315: };
! 316:
! 317: /* Returns the name of the command (and possibly sub-command) with the given
! 318: command code and feature register values. For most command codes this
! 319: simply returns the corresponding entry in the command_table array, but for
! 320: others the value of the feature register specifies a subcommand or
! 321: distinguishes commands. */
! 322: const char *look_up_ata_command(unsigned char c_code, unsigned char f_reg) {
! 323:
! 324: // check that command table not messed up. The compiler will issue
! 325: // warnings if there are too many array elements, but won't issue
! 326: // warnings if there are not enough of them.
! 327: if (sizeof(command_table) != sizeof(char *)*COMMAND_TABLE_SIZE){
! 328: fprintf(stderr,
! 329: "Problem in atacmdnames.c. Command Table command_table[] does\n"
! 330: "not have %d entries! It has %d entries. Please fix it.\n",
! 331: COMMAND_TABLE_SIZE, (int)(sizeof(command_table)/sizeof(char *)));
! 332: abort();
! 333: }
! 334:
! 335: switch (c_code) {
! 336: case 0x00: /* NOP */
! 337: switch (f_reg) {
! 338: case 0x00:
! 339: return "NOP [Abort queued commands]";
! 340: case 0x01:
! 341: return "NOP [Don't abort queued commands]";
! 342: default:
! 343: return "NOP [Reserved subcommand]";
! 344: }
! 345: case 0x92: /* DOWNLOAD MICROCODE */
! 346: switch (f_reg) {
! 347: case 0x01:
! 348: return "DOWNLOAD MICROCODE [Temporary]";
! 349: case 0x07:
! 350: return "DOWNLOAD MICROCODE [Save]";
! 351: default:
! 352: return "DOWNLOAD MICROCODE [Reserved subcommand]";
! 353: }
! 354: case 0xB0: /* SMART */
! 355: switch (f_reg) {
! 356: case 0xD0:
! 357: return "SMART READ DATA";
! 358: case 0xD1:
! 359: return "SMART READ ATTRIBUTE THRESHOLDS [OBS-4]";
! 360: case 0xD2:
! 361: return "SMART ENABLE/DISABLE ATTRIBUTE AUTOSAVE";
! 362: case 0xD3:
! 363: return "SMART SAVE ATTRIBUTE VALUES [OBS-6]";
! 364: case 0xD4:
! 365: return "SMART EXECUTE OFF-LINE IMMEDIATE";
! 366: case 0xD5:
! 367: return "SMART READ LOG";
! 368: case 0xD6:
! 369: return "SMART WRITE LOG";
! 370: case 0xD7:
! 371: return "SMART WRITE ATTRIBUTE THRESHOLDS [NS, OBS-4]";
! 372: case 0xD8:
! 373: return "SMART ENABLE OPERATIONS";
! 374: case 0xD9:
! 375: return "SMART DISABLE OPERATIONS";
! 376: case 0xDA:
! 377: return "SMART RETURN STATUS";
! 378: case 0xDB:
! 379: return "SMART EN/DISABLE AUTO OFFLINE [NS (SFF-8035i)]";
! 380: default:
! 381: if (f_reg >= 0xE0)
! 382: return "[Vendor specific SMART command]";
! 383: else
! 384: return "[Reserved SMART command]";
! 385: }
! 386: case 0xB1: /* DEVICE CONFIGURATION */
! 387: switch (f_reg) {
! 388: case 0xC0:
! 389: return "DEVICE CONFIGURATION RESTORE";
! 390: case 0xC1:
! 391: return "DEVICE CONFIGURATION FREEZE LOCK";
! 392: case 0xC2:
! 393: return "DEVICE CONFIGURATION IDENTIFY";
! 394: case 0xC3:
! 395: return "DEVICE CONFIGURATION SET";
! 396: default:
! 397: return "DEVICE CONFIGURATION [Reserved command]";
! 398: }
! 399: case 0xE9: /* WRITE SAME */
! 400: switch (f_reg) {
! 401: case 0x22:
! 402: return "WRITE SAME [Start specified] [RET-4]";
! 403: case 0xDD:
! 404: return "WRITE SAME [Start unspecified] [RET-4]";
! 405: default:
! 406: return "WRITE SAME [Invalid subcommand] [RET-4]";
! 407: }
! 408: case 0xEF: /* SET FEATURES */
! 409: switch (f_reg) {
! 410: case 0x01:
! 411: return "SET FEATURES [Enable 8-bit PIO]";
! 412: case 0x02:
! 413: return "SET FEATURES [Enable write cache]";
! 414: case 0x03:
! 415: return "SET FEATURES [Set transfer mode]";
! 416: case 0x04:
! 417: return "SET FEATURES [Enable auto DR] [OBS-4]";
! 418: case 0x05:
! 419: return "SET FEATURES [Enable APM]";
! 420: case 0x06:
! 421: return "SET FEATURES [Enable Pwr-Up In Standby]";
! 422: case 0x07:
! 423: return "SET FEATURES [Set device spin-up]";
! 424: case 0x09:
! 425: return "SET FEATURES [Reserved (address offset)]";
! 426: case 0x0A:
! 427: return "SET FEATURES [Enable CFA power mode 1]";
! 428: case 0x10:
! 429: return "SET FEATURES [Reserved for Serial ATA]";
! 430: case 0x20:
! 431: return "SET FEATURES [Set Time-ltd R/W WCT]";
! 432: case 0x21:
! 433: return "SET FEATURES [Set Time-ltd R/W EH]";
! 434: case 0x31:
! 435: return "SET FEATURES [Disable Media Status Notf]";
! 436: case 0x33:
! 437: return "SET FEATURES [Disable retry] [OBS-4]";
! 438: case 0x42:
! 439: return "SET FEATURES [Enable AAM]";
! 440: case 0x43:
! 441: return "SET FEATURES [Set Max Host I/F S Times]";
! 442: case 0x44:
! 443: return "SET FEATURES [Length of VS data] [OBS-4]";
! 444: case 0x54:
! 445: return "SET FEATURES [Set cache segs] [OBS-4]";
! 446: case 0x55:
! 447: return "SET FEATURES [Disable read look-ahead]";
! 448: case 0x5D:
! 449: return "SET FEATURES [Enable release interrupt]";
! 450: case 0x5E:
! 451: return "SET FEATURES [Enable SERVICE interrupt]";
! 452: case 0x66:
! 453: return "SET FEATURES [Disable revert defaults]";
! 454: case 0x77:
! 455: return "SET FEATURES [Disable ECC] [OBS-4]";
! 456: case 0x81:
! 457: return "SET FEATURES [Disable 8-bit PIO]";
! 458: case 0x82:
! 459: return "SET FEATURES [Disable write cache]";
! 460: case 0x84:
! 461: return "SET FEATURES [Disable auto DR] [OBS-4]";
! 462: case 0x85:
! 463: return "SET FEATURES [Disable APM]";
! 464: case 0x86:
! 465: return "SET FEATURES [Disable Pwr-Up In Standby]";
! 466: case 0x88:
! 467: return "SET FEATURES [Disable ECC] [OBS-4]";
! 468: case 0x89:
! 469: return "SET FEATURES [Reserved (address offset)]";
! 470: case 0x8A:
! 471: return "SET FEATURES [Disable CFA power mode 1]";
! 472: case 0x90:
! 473: return "SET FEATURES [Reserved for Serial ATA]";
! 474: case 0x95:
! 475: return "SET FEATURES [Enable Media Status Notf]";
! 476: case 0x99:
! 477: return "SET FEATURES [Enable retries] [OBS-4]";
! 478: case 0x9A:
! 479: return "SET FEATURES [Set max avg curr] [OBS-4]";
! 480: case 0xAA:
! 481: return "SET FEATURES [Enable read look-ahead]";
! 482: case 0xAB:
! 483: return "SET FEATURES [Set max prefetch] [OBS-4]";
! 484: case 0xBB:
! 485: return "SET FEATURES [4 bytes VS data] [OBS-4]";
! 486: case 0xC2:
! 487: return "SET FEATURES [Disable AAM]";
! 488: case 0xCC:
! 489: return "SET FEATURES [Enable revert to defaults]";
! 490: case 0xDD:
! 491: return "SET FEATURES [Disable release interrupt]";
! 492: case 0xDE:
! 493: return "SET FEATURES [Disable SERVICE interrupt]";
! 494: case 0xE0:
! 495: return "SET FEATURES [Obsolete subcommand]";
! 496: default:
! 497: if (f_reg >= 0xF0)
! 498: return "SET FEATURES [Reserved for CFA]";
! 499: else
! 500: return "SET FEATURES [Reserved subcommand]";
! 501: }
! 502: case 0xF9: /* SET MAX */
! 503: switch (f_reg) {
! 504: case 0x00:
! 505: return "SET MAX ADDRESS [OBS-6]";
! 506: case 0x01:
! 507: return "SET MAX SET PASSWORD";
! 508: case 0x02:
! 509: return "SET MAX LOCK";
! 510: case 0x03:
! 511: return "SET MAX UNLOCK";
! 512: case 0x04:
! 513: return "SET MAX FREEZE LOCK";
! 514: default:
! 515: return "[Reserved SET MAX command]";
! 516: }
! 517: default:
! 518: return command_table[c_code];
! 519: }
! 520: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>