File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / smartmontools / ataidentify.cpp
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Jul 22 01:17:35 2013 UTC (10 years, 10 months ago) by misho
Branches: smartmontools, elwix, MAIN
CVS tags: v6_2, v6_1p0, v6_1, HEAD
6.1

    1: /*
    2:  * ataidentify.cpp
    3:  *
    4:  * Home page of code is: http://smartmontools.sourceforge.net
    5:  *
    6:  * Copyright (C) 2012-13 Christian Franke <smartmontools-support@lists.sourceforge.net>
    7:  *
    8:  * This program is free software; you can redistribute it and/or modify
    9:  * it under the terms of the GNU General Public License as published by
   10:  * the Free Software Foundation; either version 2, or (at your option)
   11:  * any later version.
   12:  *
   13:  * You should have received a copy of the GNU General Public License
   14:  * (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
   15:  *
   16:  */
   17: 
   18: #include "config.h"
   19: #include "ataidentify.h"
   20: 
   21: const char * ataidentify_cpp_cvsid = "$Id: ataidentify.cpp,v 1.1.1.1 2013/07/22 01:17:35 misho Exp $"
   22:   ATAIDENTIFY_H_CVSID;
   23: 
   24: #include "int64.h"
   25: #include "utility.h"
   26: 
   27: 
   28: // Table 12 of X3T10/0948D (ATA-2) Revision 4c, March 18, 1996
   29: // Table 9 of X3T13/2008D (ATA-3) Revision 7b, January 27, 1997
   30: // Tables 11 and 13 of T13/1153D (ATA/ATAPI-4) revision 18, August 19, 1998
   31: // Tables 20 and 22 of T13/1321D (ATA/ATAPI-5) Revision 3, February 29, 2000
   32: // Tables 27 and 29 of T13/1410D (ATA/ATAPI-6) Revision 3b, February 26, 2002
   33: // Tables 16 and 18 of T13/1532D (ATA/ATAPI-7) Volume 1 Revision 4b, April 21, 2004
   34: // Tables 29 and 39 of T13/1699-D (ATA8-ACS) Revision 6a, September 6, 2008
   35: // Tables 50 and 61 of T13/2015-D (ACS-2) Revision 7, June 22, 2011
   36: // Tables 51 and 56 of T13/2161-D (ACS-3) Revision 4g, February 27, 2013
   37: 
   38: const char * const identify_descriptions[] = {
   39:   "  0 General configuration",
   40:     ". 15 Device identifier: 0 = ATA, 1 = ATAPI",
   41:     ". 14:8 ATA: Vendor specific [RET-3]",
   42:     ". 14 ATAPI: Must be set to 0",
   43:     ". 13 ATAPI: Reserved",
   44:     ". 12:8 ATAPI: Command set: 0x05 = CD/DVD",
   45:     ". 7 Removable media device",
   46:     ". 6 ATA: Not removable controller and/or device [OBS-6]",
   47:     ". 5:3 ATA: Vendor specific [RET-3]",
   48:     ". 6:5 ATAPI: DRQ after PACKET cmd: 0x0 = 3ms, 0x2 = 50us",
   49:     ". 4:3 ATAPI: Reserved",
   50:     ". 2 Response incomplete",
   51:     ". 1 ATA: Vendor specific [RET-3]",
   52:     ". 0 ATA: Reserved",
   53:     ". 1:0 ATAPI: Packet size: 0x0 = 12 byte, 0x1 = 16 byte",
   54: 
   55:   "  1 Cylinders [OBS-6]",
   56:   "  2 Specific configuration (0x37c8/738c/8c73/c837)",
   57:   "  3 Heads [OBS-6]",
   58:   "  4 Vendor specific [RET-3]",
   59:   "  5 Vendor specific [RET-3]",
   60:   "  6 Sectors per track [OBS-6]",
   61:   "  7-8 Reserved for CFA (Sectors per card)",
   62:   "  9 Vendor specific [RET-4]",
   63:   " 10-19 Serial number (String)",
   64:   " 20 Vendor specific [RET-3]",
   65:   " 21 Vendor specific [RET-3]",
   66:   " 22 Vendor specific bytes on READ/WRITE LONG [OBS-4]",
   67:   " 23-26 Firmware revision (String)",
   68:   " 27-46 Model number (String)",
   69: 
   70:   " 47 READ/WRITE MULTIPLE support",
   71:     ". 15:8 Must be set to 0x80",
   72:     ". 7:0 Maximum sectors per DRQ on READ/WRITE MULTIPLE",
   73: 
   74:   " 48 Trusted Computing feature set options",
   75:     ". 15:14 Must be set to 0x1",
   76:     ". 13:1 Reserved for the Trusted Computing Group",
   77:     ". 0 Trusted Computing feature set supported",
   78: 
   79:   " 49 Capabilities",
   80:     ". 15:14 ATA: Reserved for IDENTIFY PACKET DEVICE",
   81:     ". 15 ATAPI: Interleaved DMA supported [OBS-8]",
   82:     ". 14 ATAPI: Command queuing supported [OBS-8]",
   83:     ". 13 ATA: Standard standby timer values supported",
   84:     ". 13 ATAPI: Overlap operation supported [OBS-8]",
   85:     ". 12 ATA: Reserved for IDENTIFY PACKET DEVICE",
   86:     ". 12 ATAPI: ATA software reset required [OBS-5]",
   87:     ". 11 IORDY supported",
   88:     ". 10 IORDY may be disabled",
   89:     ". 9 LBA supported",
   90:     ". 8 DMA supported",
   91:     ". 7:0 Vendor specific [RET-4]",
   92: 
   93:   " 50 Capabilities",
   94:     ". 15:14 Must be set to 0x1",
   95:     ". 13:2 Reserved",
   96:     ". 1 Reserved [OBS-6]",
   97:     ". 0 Vendor specific minimum standby timer value",
   98: 
   99:   " 51 PIO data transfer mode [OBS-5]",
  100:   " 52 Single Word DMA data transfer mode [OBS-3]",
  101: 
  102:   " 53 Field validity / Free-fall Control",
  103:     ". 15:8 Free-fall Control sensitivity",
  104:     ". 7:3 Reserved",
  105:     ". 2 Word 88 (Ultra DMA modes) is valid",
  106:     ". 1 Words 64-70 (PIO modes) are valid",
  107:     ". 0 Words 54-58 (CHS) are valid [OBS-6]",
  108: 
  109:   " 54 Current cylinders [OBS-6]",
  110:   " 55 Current heads [OBS-6]",
  111:   " 56 Current sectors per track [OBS-6]",
  112:   " 57-58 Current capacity in sectors (DWord) [OBS-6]",
  113: 
  114:   " 59 Sanitize Device - READ/WRITE MULTIPLE support",
  115:     ". 15 BLOCK ERASE EXT supported",
  116:     ". 14 OVERWRITE EXT supported",
  117:     ". 13 CRYPTO SCRAMBLE EXT supported",
  118:     ". 12 Sanitize Device feature set supported",
  119:     ". 11:9 Reserved",
  120:     ". 8 Bits 7:0 are valid",
  121:     ". 7:0 Current sectors per DRQ on READ/WRITE MULTIPLE",
  122: 
  123:   " 60-61 User addressable sectors for 28-bit commands (DWord)",
  124:   " 62 Single Word DMA modes [OBS-3]",
  125: 
  126:   " 63 Multiword DMA modes",
  127:     ". 15:11 Reserved",
  128:     ". 10 Multiword DMA mode 2 selected",
  129:     ". 9 Multiword DMA mode 1 selected",
  130:     ". 8 Multiword DMA mode 0 selected",
  131:     ". 7:3 Reserved",
  132:     ". 2 Multiword DMA mode 2 and below supported",
  133:     ". 1 Multiword DMA mode 1 and below supported",
  134:     ". 0 Multiword DMA mode 0 supported",
  135: 
  136:   " 64 PIO modes",
  137:     ". 15:2 Reserved",
  138:     ". 1 PIO mode 4 supported",
  139:     ". 0 PIO mode 3 supported",
  140: 
  141:   " 65 Minimum Multiword DMA cycle time per word in ns",
  142:   " 66 Recommended Multiword DMA cycle time in ns",
  143:   " 67 Minimum PIO cycle time without flow control in ns",
  144:   " 68 Minimum PIO cycle time with IORDY flow control in ns",
  145: 
  146:   " 69 Additional support",
  147:     ". 15 CFast specification supported",
  148:     ". 14 Deterministic data after trim supported",
  149:     ". 13 LPS Alignment Error Reporting Control supported",
  150:     ". 12 DCO IDENTIFY/SET DMA supported [OBS-ACS-3]",
  151:     ". 11 READ BUFFER DMA supported",
  152:     ". 10 WRITE BUFFER DMA supported",
  153:     ". 9 SET MAX SET PASSWORD/UNLOCK DMA supported [OBS-ACS-3]",
  154:     ". 8 DOWNLOAD MICROCODE DMA supported",
  155:     ". 7 Reserved for IEEE 1667",
  156:     ". 6 Optional ATA device 28-bit commands supported",
  157:     ". 5 Trimmed LBA range(s) returning zeroed data supported",
  158:     ". 4 Device encrypts all user data",
  159:     ". 3 Extended number of user addressable sectors supported",
  160:     ". 2 All write cache is non-volatile",
  161:     ". 1:0 Reserved",
  162: 
  163:   " 70 Reserved",
  164:   " 71-74 ATA: Reserved for IDENTIFY PACKET DEVICE",
  165:   " 71 ATAPI: Time in ns from PACKET to bus release [OBS-8]",
  166:   " 72 ATAPI: Time in ns from SERVICE to BSY cleared [OBS-8]",
  167:   " 73-74 ATAPI: Reserved",
  168: 
  169:   " 75 Queue depth",
  170:     ". 15:5 Reserved",
  171:     ". 4:0 Maximum queue depth - 1",
  172: 
  173:   " 76 Serial ATA capabilities",
  174:     ". 15 READ LOG DMA EXT as equiv to READ LOG EXT supported",
  175:     ". 14 Device Auto Partial to Slumber transitions supported",
  176:     ". 13 Host Auto Partial to Slumber transitions supported",
  177:     ". 12 NCQ priority information supported",
  178:     ". 11 Unload while NCQ commands are outstanding supported",
  179:     ". 10 Phy Event Counters supported",
  180:     ". 9 Receipt of host initiated PM requests supported",
  181:     ". 8 NCQ feature set supported",
  182:     ". 7:4 Reserved for Serial ATA",
  183:     ". 3 SATA Gen3 signaling speed (6.0 Gb/s) supported",
  184:     ". 2 SATA Gen2 signaling speed (3.0 Gb/s) supported",
  185:     ". 1 SATA Gen1 signaling speed (1.5 Gb/s) supported",
  186:     ". 0 Must be set to 0",
  187: 
  188:   " 77 Serial ATA additional capabilities", // ACS-3
  189:     ". 15:7 Reserved for Serial ATA",
  190:     ". 6 RECEIVE/SEND FPDMA QUEUED supported",
  191:     ". 5 NCQ Queue Management supported",
  192:     ". 4 NCQ Streaming supported",
  193:     ". 3:1 Current Serial ATA signal speed",
  194:     ". 0 Must be set to 0",
  195: 
  196:   " 78 Serial ATA features supported",
  197:     ". 15:8 Reserved for Serial ATA",
  198:     ". 7 NCQ Autosense supported", // ACS-3
  199:     ". 6 Software Settings Preservation supported",
  200:     ". 5 Hardware Feature Control supported", // ACS-3
  201:     ". 4 In-order data delivery supported",
  202:     ". 3 Device initiated power management supported",
  203:     ". 2 DMA Setup auto-activation supported",
  204:     ". 1 Non-zero buffer offsets supported",
  205:     ". 0 Must be set to 0",
  206: 
  207:   " 79 Serial ATA features enabled",
  208:     ". 15:8 Reserved for Serial ATA",
  209:     ". 7 Automatic Partial to Slumber transitions enabled", // ACS-3
  210:     ". 6 Software Settings Preservation enabled",
  211:     ". 5 Hardware Feature Control enabled", // ACS-3
  212:     ". 4 In-order data delivery enabled",
  213:     ". 3 Device initiated power management enabled",
  214:     ". 2 DMA Setup auto-activation enabled",
  215:     ". 1 Non-zero buffer offsets enabled",
  216:     ". 0 Must be set to 0",
  217: 
  218:   " 80 Major version number",
  219:     ". 15:11 Reserved",
  220:     ". 10 ACS-3 supported",
  221:     ". 9 ACS-2 supported",
  222:     ". 8 ATA8-ACS supported",
  223:     ". 7 ATA/ATAPI-7 supported",
  224:     ". 6 ATA/ATAPI-6 supported",
  225:     ". 5 ATA/ATAPI-5 supported",
  226:     ". 4 ATA/ATAPI-4 supported [OBS-8]",
  227:     ". 3 ATA-3 supported [OBS-7]",
  228:     ". 2 ATA-2 supported [OBS-6]",
  229:     ". 1 ATA-1 supported [OBS-5]",
  230:     ". 0 Reserved",
  231: 
  232:   " 81 Minor version number",
  233: 
  234:   " 82 Commands and feature sets supported",
  235:     ". 15 IDENTIFY DEVICE DMA supported [OBS-4]", // ATA-4 r07-r14 only
  236:     ". 14 NOP supported",
  237:     ". 13 READ BUFFER supported",
  238:     ". 12 WRITE BUFFER supported",
  239:     ". 11 WRITE VERIFY supported [OBS-4]", // ATA-4 r07-r13 only
  240:     ". 10 HPA feature set supported [OBS-ACS-3]",
  241:     ". 9 DEVICE RESET supported", // ATA:0, ATAPI:1
  242:     ". 8 SERVICE interrupt supported [OBS-ACS-2]",
  243:     ". 7 Release interrupt supported [OBS-ACS-2]",
  244:     ". 6 Read look-ahead supported",
  245:     ". 5 Volatile write cache supported",
  246:     ". 4 PACKET feature set supported", // ATA:0, ATAPI:1
  247:     ". 3 Power Management feature set supported",
  248:     ". 2 Removable Media feature set supported [OBS-8]",
  249:     ". 1 Security feature set supported",
  250:     ". 0 SMART feature set supported",
  251: 
  252:   " 83 Commands and feature sets supported",
  253:     ". 15:14 Must be set to 0x1",
  254:     ". 13 FLUSH CACHE EXT supported",
  255:     ". 12 FLUSH CACHE supported",
  256:     ". 11 DCO feature set supported [OBS-ACS-3]",
  257:     ". 10 48-bit Address feature set supported",
  258:     ". 9 AAM feature set supported [OBS-ACS-2]",
  259:     ". 8 SET MAX security extension supported [OBS-ACS-3]",
  260:     ". 7 Reserved for Address Offset Reserved Area Boot Method",
  261:     ". 6 SET FEATURES subcommand required to spin-up",
  262:     ". 5 PUIS feature set supported",
  263:     ". 4 Removable Media Status Notification supported [OBS-8]",
  264:     ". 3 APM feature set supported",
  265:     ". 2 CFA feature set supported",
  266:     ". 1 TCQ feature set supported [OBS-ACS-2]",
  267:     ". 0 DOWNLOAD MICROCODE supported",
  268: 
  269:   " 84 Commands and feature sets supported",
  270:     ". 15:14 Must be set to 0x1",
  271:     ". 13 IDLE IMMEDIATE with UNLOAD feature supported",
  272:     ". 12:11 Reserved for TLC [OBS-ACS-3]",
  273:     ". 10 URG bit for WRITE STREAM (DMA) EXT supported [OBS-8]",
  274:     ". 9 URG bit for READ STREAM (DMA) EXT supported [OBS-8]",
  275:     ". 8 64-bit World Wide Name supported",
  276:     ". 7 WRITE DMA QUEUED FUA EXT supported",
  277:     ". 6 WRITE DMA/MULTIPLE FUA EXT supported",
  278:     ". 5 GPL feature set supported",
  279:     ". 4 Streaming feature set supported [OBS-ACS-3]",
  280:     ". 3 Media Card Pass Through Command supported [OBS-ACS-2]",
  281:     ". 2 Media serial number supported", // ACS-3 r3 or later: Reserved
  282:     ". 1 SMART self-test supported",
  283:     ". 0 SMART error logging supported",
  284: 
  285:   " 85 Commands and feature sets supported or enabled",
  286:     ". 15 IDENTIFY DEVICE DMA supported [OBS-4]", // ATA-4 r07-r14 only
  287:     ". 14 NOP supported",
  288:     ". 13 READ BUFFER supported",
  289:     ". 12 WRITE BUFFER supported",
  290:     ". 11 WRITE VERIFY supported [OBS-4]", // ATA-4 r07-r13 only
  291:     ". 10 HPA feature set supported [OBS-ACS-3]",
  292:     ". 9 DEVICE RESET supported", // ATA:0, ATAPI:1
  293:     ". 8 SERVICE interrupt enabled [OBS-ACS-2]",
  294:     ". 7 Release interrupt enabled [OBS-ACS-2]",
  295:     ". 6 Read look-ahead enabled",
  296:     ". 5 Write cache enabled",
  297:     ". 4 PACKET feature set supported", // ATA:0, ATAPI:1
  298:     ". 3 Power Management feature set supported",
  299:     ". 2 Removable Media feature set supported [OBS-8]",
  300:     ". 1 Security feature set enabled",
  301:     ". 0 SMART feature set enabled",
  302: 
  303:   " 86 Commands and feature sets supported or enabled",
  304:     ". 15 Words 119-120 are valid",
  305:     ". 14 Reserved",
  306:     ". 13 FLUSH CACHE EXT supported",
  307:     ". 12 FLUSH CACHE supported",
  308:     ". 11 DCO feature set supported [OBS-ACS-3]",
  309:     ". 10 48-bit Address features set supported",
  310:     ". 9 AAM feature set enabled [OBS-ACS-2]",
  311:     ". 8 SET MAX security extension enabled [OBS-ACS-3]",
  312:     ". 7 Reserved for Address Offset Reserved Area Boot Method",
  313:     ". 6 SET FEATURES subcommand required to spin-up",
  314:     ". 5 PUIS feature set enabled",
  315:     ". 4 Removable Media Status Notification enabled [OBS-8]",
  316:     ". 3 APM feature set enabled",
  317:     ". 2 CFA feature set supported",
  318:     ". 1 TCQ feature set supported [OBS-ACS-2]",
  319:     ". 0 DOWNLOAD MICROCODE supported",
  320: 
  321:   " 87 Commands and feature sets supported or enabled",
  322:     ". 15:14 Must be set to 0x1",
  323:     ". 13 IDLE IMMEDIATE with UNLOAD FEATURE supported",
  324:     ". 12:11 Reserved for TLC [OBS-ACS-3]",
  325:     ". 10 URG bit for WRITE STREAM (DMA) EXT supported [OBS-8]",
  326:     ". 9 URG bit for READ STREAM (DMA) EXT supported [OBS-8]",
  327:     ". 8 64-bit World Wide Name supported",
  328:     ". 7 WRITE DMA QUEUED FUA EXT supported [OBS-ACS-2]",
  329:     ". 6 WRITE DMA/MULTIPLE FUA EXT supported",
  330:     ". 5 GPL feature set supported",
  331:     ". 4 Valid CONFIGURE STREAM has been executed [OBS-8]",
  332:     ". 3 Media Card Pass Through Command supported [OBS-ACS-2]",
  333:     ". 2 Media serial number is valid",
  334:     ". 1 SMART self-test supported",
  335:     ". 0 SMART error logging supported",
  336: 
  337:   " 88 Ultra DMA modes",
  338:     ". 15 Reserved",
  339:     ". 14 Ultra DMA mode 6 selected",
  340:     ". 13 Ultra DMA mode 5 selected",
  341:     ". 12 Ultra DMA mode 4 selected",
  342:     ". 11 Ultra DMA mode 3 selected",
  343:     ". 10 Ultra DMA mode 2 selected",
  344:     ". 9 Ultra DMA mode 1 selected",
  345:     ". 8 Ultra DMA mode 0 selected",
  346:     ". 7 Reserved",
  347:     ". 6 Ultra DMA mode 6 and below supported",
  348:     ". 5 Ultra DMA mode 5 and below supported",
  349:     ". 4 Ultra DMA mode 4 and below supported",
  350:     ". 3 Ultra DMA mode 3 and below supported",
  351:     ". 2 Ultra DMA mode 2 and below supported",
  352:     ". 1 Ultra DMA mode 1 and below supported",
  353:     ". 0 Ultra DMA mode 0 supported",
  354: 
  355:   " 89 SECURITY ERASE UNIT time",
  356:   " 90 ENHANCED SECURITY ERASE UNIT time",
  357:   " 91 Current APM level",
  358:   " 92 Master password revision code",
  359: 
  360:   " 93 Hardware reset result (PATA)",
  361:     ". 15:14 Must be set to 0x1",
  362:     ". 13 Device detected CBLID- above(1)/below(0) ViHB",
  363:     ". 12 Reserved",
  364:     ". 11 Device 1 asserted PDIAG-",
  365:     ". 10:9 Device 1 detection method: -, Jumper, CSEL, other",
  366:     ". 8 Must be set to 1",
  367:     ". 7 Reserved",
  368:     ". 6 Device 0 responds when device 1 selected",
  369:     ". 5 Device 0 detected the assertion of DASP-",
  370:     ". 4 Device 0 detected the assertion of PDIAG-",
  371:     ". 3 Device 0 passed diagnostics",
  372:     ". 2:1 Device 0 detection method: -, Jumper, CSEL, other",
  373:     ". 0 Must be set to 1",
  374: 
  375:   " 94 AAM level [OBS-ACS-2]",
  376:     ". 15:8 Recommended AAM level [OBS-ACS-2]",
  377:     ". 7:0 Current AAM level [OBS-ACS-2]",
  378: 
  379:   " 95 Stream Minimum Request Size",
  380:   " 96 Streaming Transfer Time - DMA",
  381:   " 97 Streaming Access Latency - DMA and PIO",
  382:   " 98-99 Streaming Performance Granularity (DWord)",
  383:   "100-103 User addressable sectors for 48-bit commands (QWord)",
  384:   "104 Streaming Transfer Time - PIO",
  385:   "105 Max blocks of LBA Range Entries per DS MANAGEMENT cmd",
  386: 
  387:   "106 Physical sector size / logical sector size",
  388:     ". 15:14 Must be set to 0x1",
  389:     ". 13 Multiple logical sectors per physical sector",
  390:     ". 12 Logical Sector longer than 256 words",
  391:     ". 11:4 Reserved",
  392:     ". 3:0 2^X logical sectors per physical sector",
  393: 
  394:   "107 Inter-seek delay for ISO 7779 acoustic testing",
  395:   "108-111 64-bit World Wide Name",
  396:   "112-115 Reserved for a 128-bit World Wide Name",
  397:   "116 Reserved for TLC [OBS-ACS-3]",
  398:   "117-118 Logical sector size (DWord)",
  399: 
  400:   "119 Commands and feature sets supported",
  401:     ". 15:14 Must be set to 0x1",
  402:     ". 13:10 Reserved",
  403:     ". 9 DSN feature set supported", // ACS-3
  404:     ". 8 Accessible Max Address Config feature set supported", // ACS-3
  405:     ". 7 Extended Power Conditions feature set supported",
  406:     ". 6 Sense Data Reporting feature set supported",
  407:     ". 5 Free-fall Control feature set supported",
  408:     ". 4 DOWNLOAD MICROCODE with mode 3 supported",
  409:     ". 3 READ/WRITE LOG DMA EXT supported",
  410:     ". 2 WRITE UNCORRECTABLE EXT supported",
  411:     ". 1 Write-Read-Verify feature set supported",
  412:     ". 0 Reserved for DDT [OBS-ACS-3]",
  413: 
  414:   "120 Commands and feature sets supported or enabled",
  415:     ". 15:14 Must be set to 0x1",
  416:     ". 13:10 Reserved",
  417:     ". 9 DSN feature set enabled", // ACS-3
  418:     ". 8 Reserved",
  419:     ". 7 Extended Power Conditions feature set enabled",
  420:     ". 6 Sense Data Reporting feature set enabled",
  421:     ". 5 Free-fall Control feature set enabled",
  422:     ". 4 DOWNLOAD MICROCODE with mode 3 supported",
  423:     ". 3 READ/WRITE LOG DMA EXT supported",
  424:     ". 2 WRITE UNCORRECTABLE EXT supported",
  425:     ". 1 Write-Read-Verify feature set enabled",
  426:     ". 0 Reserved for DDT [OBS-ACS-3]",
  427: 
  428:   "121-126 ATA: Reserved",
  429:   "121-124 ATAPI: Reserved",
  430:   "125 ATAPI: Byte count = 0 behavior",
  431:   "126 ATAPI: Byte count = 0 behavior [OBS-6]",
  432: 
  433:   "127 Removable Media Status Notification [OBS-8]",
  434:     ". 15:1 Reserved",
  435:     ". 0 Removable Media Status Notification supported",
  436: 
  437:   "128 Security status",
  438:     ". 15:9 Reserved",
  439:     ". 8 Master password capability: 0 = High, 1 = Maximum",
  440:     ". 7:6 Reserved",
  441:     ". 5 Enhanced security erase supported",
  442:     ". 4 Security count expired",
  443:     ". 3 Security frozen",
  444:     ". 2 Security locked",
  445:     ". 1 Security enabled",
  446:     ". 0 Security supported",
  447: 
  448:   "129-159 Vendor specific",
  449: 
  450:   "160 CFA power mode",
  451:   // ". 15 Word 160 supported",
  452:   // ". 14 Reserved",
  453:   // ". 13 CFA power mode 1 is required for some commands",
  454:   // ". 12 CFA power mode 1 disabled",
  455:   // ". 11:0 Maximum current in mA",
  456:   "161-167 Reserved for CFA",
  457: 
  458:   "168 Form factor",
  459:     ". 15:4 Reserved",
  460:     ". 3:0 Nominal form factor: -, 5.25, 3.5, 2.5, 1.8, <1.8",
  461: 
  462:   "169 Data Set Management support",
  463:     ". 15:1 Reserved",
  464:     ". 0 Trim bit in DATA SET MANAGEMENT command supported",
  465: 
  466:   "170-173 Additional product identifier (String)",
  467:   "174-175 Reserved",
  468:   "176-205 Current media serial number (String)",
  469: 
  470:   "206 SCT Command Transport",
  471:     ". 15:12 Vendor Specific",
  472:     ". 11:8 Reserved",
  473:     ". 7 Reserved for Serial ATA",
  474:     ". 6 Reserved",
  475:     ". 5 SCT Data Tables supported",
  476:     ". 4 SCT Feature Control supported",
  477:     ". 3 SCT Error Recovery Control supported",
  478:     ". 2 SCT Write Same supported",
  479:     ". 1 SCT Read/Write Long supported [OBS-ACS-2]",
  480:     ". 0 SCT Command Transport supported",
  481: 
  482:   "207-208 Reserved for CE-ATA",
  483: 
  484:   "209 Alignment of logical sectors",
  485:     ". 15:14 Must be set to 0x1",
  486:     ". 13:0 Logical sector offset",
  487: 
  488:   "210-211 Write-Read-Verify sector count mode 3 (DWord)",
  489:   "212-213 Write-Read-Verify sector count mode 2 (DWord)",
  490: 
  491:   "214 NV Cache capabilities [OBS-ACS-3]",
  492:     ". 15:12 NV Cache feature set version [OBS-ACS-3]",
  493:     ". 11:8 NV Cache Power Mode feature set version [OBS-ACS-3]",
  494:     ". 7:5 Reserved [OBS-ACS-3]",
  495:     ". 4 NV Cache feature set enabled [OBS-ACS-3]",
  496:     ". 3:2 Reserved",
  497:     ". 1 NV Cache Power Mode feature set enabled [OBS-ACS-3]",
  498:     ". 0 NV Cache Power Mode feature set supported [OBS-ACS-3]",
  499: 
  500:   "215-216 NV Cache size in logical blocks (DWord) [OBS-ACS-3]",
  501:   "217 Nominal media rotation rate",
  502:   "218 Reserved",
  503: 
  504:   "219 NV Cache options [OBS-ACS-3]",
  505:     ". 15:8 Reserved [OBS-ACS-3]",
  506:     ". 7:0 Estimated time to spin up in seconds [OBS-ACS-3]",
  507: 
  508:   "220 Write-Read-Verify mode",
  509:     ". 15:8 Reserved",
  510:     ". 7:0 Write-Read-Verify feature set current mode",
  511: 
  512:   "221 Reserved",
  513: 
  514:   "222 Transport major version number",
  515:     ". 15:12 Transport type: 0x0 = Parallel, 0x1 = Serial",
  516:     ". 11:7 Reserved    | Reserved",
  517:     ". 6 Reserved    | SATA 3.1",
  518:     ". 5 Reserved    | SATA 3.0",
  519:     ". 4 Reserved    | SATA 2.6",
  520:     ". 3 Reserved    | SATA 2.5",
  521:     ". 2 Reserved    | SATA II: Extensions",
  522:     ". 1 ATA/ATAPI-7 | SATA 1.0a",
  523:     ". 0 ATA8-APT    | ATA8-AST",
  524: 
  525:   "223 Transport minor version number",
  526:   "224-229 Reserved",
  527:   "230-233 Extended number of user addressable sectors (QWord)",
  528:   "234 Minimum blocks per DOWNLOAD MICROCODE mode 3 command",
  529:   "235 Maximum blocks per DOWNLOAD MICROCODE mode 3 command",
  530:   "236-254 Reserved",
  531: 
  532:   "255 Integrity word",
  533:     ". 15:8 Checksum",
  534:     ". 7:0 Signature"
  535: };
  536: 
  537: const int num_identify_descriptions = sizeof(identify_descriptions)/sizeof(identify_descriptions[0]);
  538: 
  539: static inline unsigned short get_word(const void * id, int word)
  540: {
  541:   const unsigned char * p = ((const unsigned char *)id) + 2 * word;
  542:   return p[0] + (p[1] << 8);
  543: }
  544: 
  545: void ata_print_identify_data(const void * id, bool all_words, int bit_level)
  546: {
  547:   // ATA or ATAPI ?
  548:   unsigned short w = get_word(id, 0);
  549:   bool is_atapi = ((w & 0x8000) && (w != 0x848a/*CompactFlash Signature*/));
  550: 
  551:   int prev_word = -1, prev_bit = -1;
  552:   pout("Word     %s Value   Description\n", (bit_level >= 0 ? "Bit    " : " "));
  553: 
  554:   for (int i = 0; i < num_identify_descriptions; i++) {
  555:     // Parse table entry
  556:     const char * desc = identify_descriptions[i];
  557: 
  558:     int word = prev_word, word2 = -1;
  559:     int bit = -1, bit2 = -1;
  560: 
  561:     int nc;
  562:     unsigned v1, v2;
  563:     if (word >= 0 && sscanf(desc, ". %u:%u %n", &v1, &v2, (nc=-1, &nc)) == 2 && nc > 0 && 16 > v1 && v1 > v2) {
  564:       bit = v1; bit2 = v2;
  565:     }
  566:     else if (word >= 0 && sscanf(desc, ". %u %n", &v1, (nc=-1, &nc)) == 1 && nc > 0 && v1 < 16) {
  567:       bit = v1;
  568:     }
  569:     else if (sscanf(desc, "%u-%u %n", &v1, &v2, (nc=-1, &nc)) == 2 && nc > 0 && v1 < v2 && v2 < 256) {
  570:       word = v1, word2 = v2;
  571:     }
  572:     else if (sscanf(desc, "%u %n", &v1, (nc=-1, &nc)) == 1 && nc > 0 && v1 < 256) {
  573:       word = v1;
  574:     }
  575:     else {
  576:       pout("Error: #%d: Syntax\n", i);
  577:       continue;
  578:     }
  579:     desc += nc;
  580: 
  581:     // Check for ATA/ATAPI specific entries
  582:     if (str_starts_with(desc, "ATA: ")) {
  583:       if (is_atapi)
  584:         continue;
  585:       desc += sizeof("ATA: ")-1;
  586:     }
  587:     else if (str_starts_with(desc, "ATAPI: ")) {
  588:       if (!is_atapi)
  589:         continue;
  590:     }
  591: 
  592:     // Check table entry
  593:     if (bit < 0) {
  594:       if (word != prev_word+1) {
  595:         pout("Error: #%d: Missing word %d\n", i, prev_word+1);
  596:         return;
  597:       }
  598:       else if (prev_bit > 0) {
  599:         pout("Error: #%d: Missing bit 0 from word %d\n", i, prev_word);
  600:         return;
  601:       }
  602:     }
  603:     else if (!((prev_bit < 0 && bit == 15) || bit == prev_bit-1)) {
  604:       pout("Error: #%d: Missing bit %d from word %d\n", i, bit+1, word);
  605:       return;
  606:     }
  607: 
  608:     w = get_word(id, word);
  609:     bool w_is_set = (w != 0x0000 && w != 0xffff);
  610: 
  611:     if (bit >= 0) {
  612:       int b;
  613:       if (bit2 >= 0)
  614:         b = (w >> bit2) & ~(~0 << (bit-bit2+1));
  615:       else
  616:         b = (w >> bit) & 1;
  617: 
  618:       if (   (bit_level >= 0 && b)
  619:           || (bit_level >= 1 && w_is_set)
  620:           || (bit_level >= 2 && all_words)) {
  621:         if (bit2 >= 0) {
  622:           // Print bitfield
  623:           char valstr[20];
  624:           snprintf(valstr, sizeof(valstr), "0x%0*x", (bit - bit2 + 4) >> 2, b);
  625:           pout("%4d     %2d:%-2d  %6s   %s\n", word, bit, bit2, valstr, desc);
  626:         }
  627:         else {
  628:           // Print bit
  629:           pout("%4d     %2d          %u   %s\n", word, bit, b, desc);
  630:         }
  631:       }
  632: 
  633:       prev_bit = (bit2 >= 0 ? bit2 : bit);
  634:     }
  635:     else {
  636:       if (word2 >= 0) {
  637:         for (int j = word+1; !w_is_set && j <= word2; j++) {
  638:            if (get_word(id, j) != w)
  639:              w_is_set = true;
  640:         }
  641: 
  642:         // Print word array
  643:         if (all_words || w_is_set) {
  644:           pout("%s%4d-%-3d  %s",
  645:                (bit_level >= 0 ? "\n" : ""), word, word2,
  646:                (bit_level >= 0 ? "-     " : ""));
  647: 
  648:           if (!w_is_set) {
  649:             pout("0x%02x...  %s\n", w & 0xff, desc);
  650:           }
  651:           else {
  652:             bool is_str = !!strstr(desc, "(String)");
  653:             pout(".        %s", desc);
  654: 
  655:             for (int j = word; j <= word2; j += 4) {
  656:               if (j + 2*4 < word2 && !nonempty((const unsigned char *)id + 2*j, 2*(word2-j+1))) {
  657:                 // Remaining words are null
  658:                 pout("\n%4d-%-3d  %s0x0000:0000:0000:00...", j, word2,
  659:                      (bit_level >= 0 ? ".     " : ""));
  660:                 break;
  661:               }
  662:               // Print 4 words in a row
  663:               pout("\n%4d-%-3d  %s0x", j, (j+3 <= word2 ? j+3 : word2),
  664:                    (bit_level >= 0 ? ".     " : ""));
  665:               int k;
  666:               for (k = 0; k < 4 && j+k <= word2; k++)
  667:                 pout("%s%04x",  (k == 0 ? "" : ":"), get_word(id, j+k));
  668: 
  669:               if (is_str) {
  670:                 // Append little endian string
  671:                 pout("%*s  \"", 20 - 5 * k, "");
  672:                 for (k = 0; k < 4 && j+k <= word2; k++) {
  673:                   char c2 = ((const char *)id)[2*(j+k)    ];
  674:                   char c1 = ((const char *)id)[2*(j+k) + 1];
  675:                   pout("%c%c", (' ' <= c1 && c1 <= '~' ? c1 : '.'),
  676:                                (' ' <= c2 && c2 <= '~' ? c2 : '.') );
  677:                 }
  678:                 pout("\"");
  679:               }
  680:             }
  681: 
  682:             // Print decimal value of D/QWords
  683:             if (word + 1 == word2 && strstr(desc, "(DWord)"))
  684:               pout("  (%u)\n", ((unsigned)get_word(id, word2) << 16) | w);
  685:             else if (word + 3 == word2 && strstr(desc, "(QWord)"))
  686:               pout("  (%"PRIu64")\n", ((uint64_t)get_word(id, word + 3) << 48)
  687:                                     | ((uint64_t)get_word(id, word + 2) << 32)
  688:                                     | ((unsigned)get_word(id, word + 1) << 16) | (unsigned)w);
  689:             else
  690:               pout("\n");
  691:           }
  692:         }
  693:       }
  694:       else {
  695:         // Print word
  696:         if (all_words || w_is_set)
  697:           pout("%s%4d      %s0x%04x   %s\n",
  698:                (bit_level >= 0 ? "\n" : ""), word,
  699:                (bit_level >= 0 ? "-     " : ""), w, desc);
  700:       }
  701: 
  702:       prev_word = (word2 >= 0 ? word2 : word);
  703:       prev_bit = -1;
  704:     }
  705:   }
  706: 
  707:   pout("\n");
  708: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>