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