diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-30 19:36:54 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-10-30 19:36:54 +0000 |
| commit | 9130340adfcfe28dff626d6306266883c0070e44 (patch) | |
| tree | ecd4e9cf47cfcdc3096535523c5483f03d6f50fc /miscutils | |
| parent | d059ddc1bbd7863f8ef8aa6484b6c3ba802b5dca (diff) | |
| download | busybox-w32-9130340adfcfe28dff626d6306266883c0070e44.tar.gz busybox-w32-9130340adfcfe28dff626d6306266883c0070e44.tar.bz2 busybox-w32-9130340adfcfe28dff626d6306266883c0070e44.zip | |
hdparm: code shrink
text data bss dec hex filename
776494 974 9420 786888 c01c8 busybox_old
776099 974 9420 786493 c003d busybox_unstripped
Diffstat (limited to 'miscutils')
| -rw-r--r-- | miscutils/hdparm.c | 443 |
1 files changed, 214 insertions, 229 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c index 869a5b246..c8129d791 100644 --- a/miscutils/hdparm.c +++ b/miscutils/hdparm.c | |||
| @@ -127,62 +127,6 @@ | |||
| 127 | 127 | ||
| 128 | #define CDROM 0x0005 | 128 | #define CDROM 0x0005 |
| 129 | 129 | ||
| 130 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY | ||
| 131 | static const char *const pkt_str[] = { | ||
| 132 | "Direct-access device", /* word 0, bits 12-8 = 00 */ | ||
| 133 | "Sequential-access device", /* word 0, bits 12-8 = 01 */ | ||
| 134 | "Printer", /* word 0, bits 12-8 = 02 */ | ||
| 135 | "Processor", /* word 0, bits 12-8 = 03 */ | ||
| 136 | "Write-once device", /* word 0, bits 12-8 = 04 */ | ||
| 137 | "CD-ROM", /* word 0, bits 12-8 = 05 */ | ||
| 138 | "Scanner", /* word 0, bits 12-8 = 06 */ | ||
| 139 | "Optical memory", /* word 0, bits 12-8 = 07 */ | ||
| 140 | "Medium changer", /* word 0, bits 12-8 = 08 */ | ||
| 141 | "Communications device", /* word 0, bits 12-8 = 09 */ | ||
| 142 | "ACS-IT8 device", /* word 0, bits 12-8 = 0a */ | ||
| 143 | "ACS-IT8 device", /* word 0, bits 12-8 = 0b */ | ||
| 144 | "Array controller", /* word 0, bits 12-8 = 0c */ | ||
| 145 | "Enclosure services", /* word 0, bits 12-8 = 0d */ | ||
| 146 | "Reduced block command device", /* word 0, bits 12-8 = 0e */ | ||
| 147 | "Optical card reader/writer", /* word 0, bits 12-8 = 0f */ | ||
| 148 | "", /* word 0, bits 12-8 = 10 */ | ||
| 149 | "", /* word 0, bits 12-8 = 11 */ | ||
| 150 | "", /* word 0, bits 12-8 = 12 */ | ||
| 151 | "", /* word 0, bits 12-8 = 13 */ | ||
| 152 | "", /* word 0, bits 12-8 = 14 */ | ||
| 153 | "", /* word 0, bits 12-8 = 15 */ | ||
| 154 | "", /* word 0, bits 12-8 = 16 */ | ||
| 155 | "", /* word 0, bits 12-8 = 17 */ | ||
| 156 | "", /* word 0, bits 12-8 = 18 */ | ||
| 157 | "", /* word 0, bits 12-8 = 19 */ | ||
| 158 | "", /* word 0, bits 12-8 = 1a */ | ||
| 159 | "", /* word 0, bits 12-8 = 1b */ | ||
| 160 | "", /* word 0, bits 12-8 = 1c */ | ||
| 161 | "", /* word 0, bits 12-8 = 1d */ | ||
| 162 | "", /* word 0, bits 12-8 = 1e */ | ||
| 163 | "Unknown", /* word 0, bits 12-8 = 1f */ | ||
| 164 | }; | ||
| 165 | |||
| 166 | static const char *const ata1_cfg_str[] = { /* word 0 in ATA-1 mode */ | ||
| 167 | "Reserved", /* bit 0 */ | ||
| 168 | "hard sectored", /* bit 1 */ | ||
| 169 | "soft sectored", /* bit 2 */ | ||
| 170 | "not MFM encoded ", /* bit 3 */ | ||
| 171 | "head switch time > 15us", /* bit 4 */ | ||
| 172 | "spindle motor control option", /* bit 5 */ | ||
| 173 | "fixed drive", /* bit 6 */ | ||
| 174 | "removable drive", /* bit 7 */ | ||
| 175 | "disk xfer rate <= 5Mbs", /* bit 8 */ | ||
| 176 | "disk xfer rate > 5Mbs, <= 10Mbs", /* bit 9 */ | ||
| 177 | "disk xfer rate > 5Mbs", /* bit 10 */ | ||
| 178 | "rotational speed tol.", /* bit 11 */ | ||
| 179 | "data strobe offset option", /* bit 12 */ | ||
| 180 | "track offset option", /* bit 13 */ | ||
| 181 | "format speed tolerance gap reqd", /* bit 14 */ | ||
| 182 | "ATAPI" /* bit 14 */ | ||
| 183 | }; | ||
| 184 | #endif | ||
| 185 | |||
| 186 | /* word 1: number of logical cylinders */ | 130 | /* word 1: number of logical cylinders */ |
| 187 | #define LCYLS_MAX 0x3fff /* maximum allowable value */ | 131 | #define LCYLS_MAX 0x3fff /* maximum allowable value */ |
| 188 | 132 | ||
| @@ -238,87 +182,6 @@ static const char *const ata1_cfg_str[] = { /* word 0 in ATA-1 mode */ | |||
| 238 | 182 | ||
| 239 | /* word 81: minor version number */ | 183 | /* word 81: minor version number */ |
| 240 | #define MINOR_MAX 0x22 | 184 | #define MINOR_MAX 0x22 |
| 241 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY | ||
| 242 | static const char *const minor_str[MINOR_MAX + 2] = { | ||
| 243 | /* word 81 value: */ | ||
| 244 | "Unspecified", /* 0x0000 */ | ||
| 245 | "ATA-1 X3T9.2 781D prior to rev.4", /* 0x0001 */ | ||
| 246 | "ATA-1 published, ANSI X3.221-1994", /* 0x0002 */ | ||
| 247 | "ATA-1 X3T9.2 781D rev.4", /* 0x0003 */ | ||
| 248 | "ATA-2 published, ANSI X3.279-1996", /* 0x0004 */ | ||
| 249 | "ATA-2 X3T10 948D prior to rev.2k", /* 0x0005 */ | ||
| 250 | "ATA-3 X3T10 2008D rev.1", /* 0x0006 */ | ||
| 251 | "ATA-2 X3T10 948D rev.2k", /* 0x0007 */ | ||
| 252 | "ATA-3 X3T10 2008D rev.0", /* 0x0008 */ | ||
| 253 | "ATA-2 X3T10 948D rev.3", /* 0x0009 */ | ||
| 254 | "ATA-3 published, ANSI X3.298-199x", /* 0x000a */ | ||
| 255 | "ATA-3 X3T10 2008D rev.6", /* 0x000b */ | ||
| 256 | "ATA-3 X3T13 2008D rev.7 and 7a", /* 0x000c */ | ||
| 257 | "ATA/ATAPI-4 X3T13 1153D rev.6", /* 0x000d */ | ||
| 258 | "ATA/ATAPI-4 T13 1153D rev.13", /* 0x000e */ | ||
| 259 | "ATA/ATAPI-4 X3T13 1153D rev.7", /* 0x000f */ | ||
| 260 | "ATA/ATAPI-4 T13 1153D rev.18", /* 0x0010 */ | ||
| 261 | "ATA/ATAPI-4 T13 1153D rev.15", /* 0x0011 */ | ||
| 262 | "ATA/ATAPI-4 published, ANSI INCITS 317-1998", /* 0x0012 */ | ||
| 263 | "ATA/ATAPI-5 T13 1321D rev.3", /* 0x0013 */ | ||
| 264 | "ATA/ATAPI-4 T13 1153D rev.14", /* 0x0014 */ | ||
| 265 | "ATA/ATAPI-5 T13 1321D rev.1", /* 0x0015 */ | ||
| 266 | "ATA/ATAPI-5 published, ANSI INCITS 340-2000", /* 0x0016 */ | ||
| 267 | "ATA/ATAPI-4 T13 1153D rev.17", /* 0x0017 */ | ||
| 268 | "ATA/ATAPI-6 T13 1410D rev.0", /* 0x0018 */ | ||
| 269 | "ATA/ATAPI-6 T13 1410D rev.3a", /* 0x0019 */ | ||
| 270 | "ATA/ATAPI-7 T13 1532D rev.1", /* 0x001a */ | ||
| 271 | "ATA/ATAPI-6 T13 1410D rev.2", /* 0x001b */ | ||
| 272 | "ATA/ATAPI-6 T13 1410D rev.1", /* 0x001c */ | ||
| 273 | "ATA/ATAPI-7 published, ANSI INCITS 397-2005", /* 0x001d */ | ||
| 274 | "ATA/ATAPI-7 T13 1532D rev.0", /* 0x001e */ | ||
| 275 | "Reserved" /* 0x001f */ | ||
| 276 | "Reserved" /* 0x0020 */ | ||
| 277 | "ATA/ATAPI-7 T13 1532D rev.4a", /* 0x0021 */ | ||
| 278 | "ATA/ATAPI-6 published, ANSI INCITS 361-2002", /* 0x0022 */ | ||
| 279 | "Reserved" /* 0x0023-0xfffe */ | ||
| 280 | }; | ||
| 281 | #endif | ||
| 282 | static const char actual_ver[MINOR_MAX + 2] ALIGN1 = { | ||
| 283 | /* word 81 value: */ | ||
| 284 | 0, /* 0x0000 WARNING: actual_ver[] array */ | ||
| 285 | 1, /* 0x0001 WARNING: corresponds */ | ||
| 286 | 1, /* 0x0002 WARNING: *exactly* */ | ||
| 287 | 1, /* 0x0003 WARNING: to the ATA/ */ | ||
| 288 | 2, /* 0x0004 WARNING: ATAPI version */ | ||
| 289 | 2, /* 0x0005 WARNING: listed in */ | ||
| 290 | 3, /* 0x0006 WARNING: the */ | ||
| 291 | 2, /* 0x0007 WARNING: minor_str */ | ||
| 292 | 3, /* 0x0008 WARNING: array */ | ||
| 293 | 2, /* 0x0009 WARNING: above. */ | ||
| 294 | 3, /* 0x000a WARNING: */ | ||
| 295 | 3, /* 0x000b WARNING: If you change */ | ||
| 296 | 3, /* 0x000c WARNING: that one, */ | ||
| 297 | 4, /* 0x000d WARNING: change this one */ | ||
| 298 | 4, /* 0x000e WARNING: too!!! */ | ||
| 299 | 4, /* 0x000f */ | ||
| 300 | 4, /* 0x0010 */ | ||
| 301 | 4, /* 0x0011 */ | ||
| 302 | 4, /* 0x0012 */ | ||
| 303 | 5, /* 0x0013 */ | ||
| 304 | 4, /* 0x0014 */ | ||
| 305 | 5, /* 0x0015 */ | ||
| 306 | 5, /* 0x0016 */ | ||
| 307 | 4, /* 0x0017 */ | ||
| 308 | 6, /* 0x0018 */ | ||
| 309 | 6, /* 0x0019 */ | ||
| 310 | 7, /* 0x001a */ | ||
| 311 | 6, /* 0x001b */ | ||
| 312 | 6, /* 0x001c */ | ||
| 313 | 7, /* 0x001d */ | ||
| 314 | 7, /* 0x001e */ | ||
| 315 | 0, /* 0x001f */ | ||
| 316 | 0, /* 0x0020 */ | ||
| 317 | 7, /* 0x0021 */ | ||
| 318 | 6, /* 0x0022 */ | ||
| 319 | 0 /* 0x0023-0xfffe */ | ||
| 320 | }; | ||
| 321 | |||
| 322 | /* words 82-84: cmds/feats supported */ | 185 | /* words 82-84: cmds/feats supported */ |
| 323 | #define CMDS_W82 0x77ff /* word 82: defined command locations*/ | 186 | #define CMDS_W82 0x77ff /* word 82: defined command locations*/ |
| 324 | #define CMDS_W83 0x3fff /* word 83: defined command locations*/ | 187 | #define CMDS_W83 0x3fff /* word 83: defined command locations*/ |
| @@ -326,62 +189,6 @@ static const char actual_ver[MINOR_MAX + 2] ALIGN1 = { | |||
| 326 | #define SUPPORT_48_BIT 0x0400 | 189 | #define SUPPORT_48_BIT 0x0400 |
| 327 | #define NUM_CMD_FEAT_STR 48 | 190 | #define NUM_CMD_FEAT_STR 48 |
| 328 | 191 | ||
| 329 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY | ||
| 330 | static const char *const cmd_feat_str[] = { | ||
| 331 | "", /* word 82 bit 15: obsolete */ | ||
| 332 | "NOP cmd", /* word 82 bit 14 */ | ||
| 333 | "READ BUFFER cmd", /* word 82 bit 13 */ | ||
| 334 | "WRITE BUFFER cmd", /* word 82 bit 12 */ | ||
| 335 | "", /* word 82 bit 11: obsolete */ | ||
| 336 | "Host Protected Area feature set", /* word 82 bit 10 */ | ||
| 337 | "DEVICE RESET cmd", /* word 82 bit 9 */ | ||
| 338 | "SERVICE interrupt", /* word 82 bit 8 */ | ||
| 339 | "Release interrupt", /* word 82 bit 7 */ | ||
| 340 | "Look-ahead", /* word 82 bit 6 */ | ||
| 341 | "Write cache", /* word 82 bit 5 */ | ||
| 342 | "PACKET command feature set", /* word 82 bit 4 */ | ||
| 343 | "Power Management feature set", /* word 82 bit 3 */ | ||
| 344 | "Removable Media feature set", /* word 82 bit 2 */ | ||
| 345 | "Security Mode feature set", /* word 82 bit 1 */ | ||
| 346 | "SMART feature set", /* word 82 bit 0 */ | ||
| 347 | /* -------------- */ | ||
| 348 | "", /* word 83 bit 15: !valid bit */ | ||
| 349 | "", /* word 83 bit 14: valid bit */ | ||
| 350 | "FLUSH CACHE EXT cmd", /* word 83 bit 13 */ | ||
| 351 | "Mandatory FLUSH CACHE cmd ", /* word 83 bit 12 */ | ||
| 352 | "Device Configuration Overlay feature set ", | ||
| 353 | "48-bit Address feature set ", /* word 83 bit 10 */ | ||
| 354 | "", | ||
| 355 | "SET MAX security extension", /* word 83 bit 8 */ | ||
| 356 | "Address Offset Reserved Area Boot", /* word 83 bit 7 */ | ||
| 357 | "SET FEATURES subcommand required to spinup after power up", | ||
| 358 | "Power-Up In Standby feature set", /* word 83 bit 5 */ | ||
| 359 | "Removable Media Status Notification feature set", | ||
| 360 | "Adv. Power Management feature set", /* word 83 bit 3 */ | ||
| 361 | "CFA feature set", /* word 83 bit 2 */ | ||
| 362 | "READ/WRITE DMA QUEUED", /* word 83 bit 1 */ | ||
| 363 | "DOWNLOAD MICROCODE cmd", /* word 83 bit 0 */ | ||
| 364 | /* -------------- */ | ||
| 365 | "", /* word 84 bit 15: !valid bit */ | ||
| 366 | "", /* word 84 bit 14: valid bit */ | ||
| 367 | "", /* word 84 bit 13: reserved */ | ||
| 368 | "", /* word 84 bit 12: reserved */ | ||
| 369 | "", /* word 84 bit 11: reserved */ | ||
| 370 | "", /* word 84 bit 10: reserved */ | ||
| 371 | "", /* word 84 bit 9: reserved */ | ||
| 372 | "", /* word 84 bit 8: reserved */ | ||
| 373 | "", /* word 84 bit 7: reserved */ | ||
| 374 | "", /* word 84 bit 6: reserved */ | ||
| 375 | "General Purpose Logging feature set", /* word 84 bit 5 */ | ||
| 376 | "", /* word 84 bit 4: reserved */ | ||
| 377 | "Media Card Pass Through Command feature set ", | ||
| 378 | "Media serial number ", /* word 84 bit 2 */ | ||
| 379 | "SMART self-test ", /* word 84 bit 1 */ | ||
| 380 | "SMART error logging " /* word 84 bit 0 */ | ||
| 381 | }; | ||
| 382 | #endif | ||
| 383 | |||
| 384 | |||
| 385 | /* words 85-87: cmds/feats enabled */ | 192 | /* words 85-87: cmds/feats enabled */ |
| 386 | /* use cmd_feat_str[] to display what commands and features have | 193 | /* use cmd_feat_str[] to display what commands and features have |
| 387 | * been enabled with words 85-87 | 194 | * been enabled with words 85-87 |
| @@ -408,16 +215,6 @@ static const char *const cmd_feat_str[] = { | |||
| 408 | #define SECU_ENABLED 0x0002 | 215 | #define SECU_ENABLED 0x0002 |
| 409 | #define SECU_LEVEL 0x0010 | 216 | #define SECU_LEVEL 0x0010 |
| 410 | #define NUM_SECU_STR 6 | 217 | #define NUM_SECU_STR 6 |
| 411 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY | ||
| 412 | static const char *const secu_str[] = { | ||
| 413 | "supported", /* word 128, bit 0 */ | ||
| 414 | "enabled", /* word 128, bit 1 */ | ||
| 415 | "locked", /* word 128, bit 2 */ | ||
| 416 | "frozen", /* word 128, bit 3 */ | ||
| 417 | "expired: security count", /* word 128, bit 4 */ | ||
| 418 | "supported: enhanced erase" /* word 128, bit 5 */ | ||
| 419 | }; | ||
| 420 | #endif | ||
| 421 | 218 | ||
| 422 | /* word 160: CFA power mode */ | 219 | /* word 160: CFA power mode */ |
| 423 | #define VALID_W160 0x8000 /* 1=word valid */ | 220 | #define VALID_W160 0x8000 /* 1=word valid */ |
| @@ -694,8 +491,195 @@ static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t * | |||
| 694 | return err_dma; | 491 | return err_dma; |
| 695 | } | 492 | } |
| 696 | 493 | ||
| 697 | // Parse 512 byte disk identification block and print much crap. | 494 | static const char *nth_str(const char *strings, int n) |
| 495 | { | ||
| 496 | while (n) { | ||
| 497 | n--; | ||
| 498 | strings += strlen(strings) + 1; | ||
| 499 | } | ||
| 500 | return strings; | ||
| 501 | } | ||
| 698 | 502 | ||
| 503 | static const char pkt_str[] ALIGN1 = | ||
| 504 | "Direct-access device" "\0" /* word 0, bits 12-8 = 00 */ | ||
| 505 | "Sequential-access device" "\0" /* word 0, bits 12-8 = 01 */ | ||
| 506 | "Printer" "\0" /* word 0, bits 12-8 = 02 */ | ||
| 507 | "Processor" "\0" /* word 0, bits 12-8 = 03 */ | ||
| 508 | "Write-once device" "\0" /* word 0, bits 12-8 = 04 */ | ||
| 509 | "CD-ROM" "\0" /* word 0, bits 12-8 = 05 */ | ||
| 510 | "Scanner" "\0" /* word 0, bits 12-8 = 06 */ | ||
| 511 | "Optical memory" "\0" /* word 0, bits 12-8 = 07 */ | ||
| 512 | "Medium changer" "\0" /* word 0, bits 12-8 = 08 */ | ||
| 513 | "Communications device" "\0" /* word 0, bits 12-8 = 09 */ | ||
| 514 | "ACS-IT8 device" "\0" /* word 0, bits 12-8 = 0a */ | ||
| 515 | "ACS-IT8 device" "\0" /* word 0, bits 12-8 = 0b */ | ||
| 516 | "Array controller" "\0" /* word 0, bits 12-8 = 0c */ | ||
| 517 | "Enclosure services" "\0" /* word 0, bits 12-8 = 0d */ | ||
| 518 | "Reduced block command device" "\0" /* word 0, bits 12-8 = 0e */ | ||
| 519 | "Optical card reader/writer" "\0" /* word 0, bits 12-8 = 0f */ | ||
| 520 | ; | ||
| 521 | |||
| 522 | static const char ata1_cfg_str[] ALIGN1 = /* word 0 in ATA-1 mode */ | ||
| 523 | "reserved" "\0" /* bit 0 */ | ||
| 524 | "hard sectored" "\0" /* bit 1 */ | ||
| 525 | "soft sectored" "\0" /* bit 2 */ | ||
| 526 | "not MFM encoded " "\0" /* bit 3 */ | ||
| 527 | "head switch time > 15us" "\0" /* bit 4 */ | ||
| 528 | "spindle motor control option" "\0" /* bit 5 */ | ||
| 529 | "fixed drive" "\0" /* bit 6 */ | ||
| 530 | "removable drive" "\0" /* bit 7 */ | ||
| 531 | "disk xfer rate <= 5Mbs" "\0" /* bit 8 */ | ||
| 532 | "disk xfer rate > 5Mbs, <= 10Mbs" "\0" /* bit 9 */ | ||
| 533 | "disk xfer rate > 5Mbs" "\0" /* bit 10 */ | ||
| 534 | "rotational speed tol." "\0" /* bit 11 */ | ||
| 535 | "data strobe offset option" "\0" /* bit 12 */ | ||
| 536 | "track offset option" "\0" /* bit 13 */ | ||
| 537 | "format speed tolerance gap reqd" "\0" /* bit 14 */ | ||
| 538 | "ATAPI" /* bit 14 */ | ||
| 539 | ; | ||
| 540 | |||
| 541 | static const char minor_str[] ALIGN1 = | ||
| 542 | /* word 81 value: */ | ||
| 543 | "Unspecified" "\0" /* 0x0000 */ | ||
| 544 | "ATA-1 X3T9.2 781D prior to rev.4" "\0" /* 0x0001 */ | ||
| 545 | "ATA-1 published, ANSI X3.221-1994" "\0" /* 0x0002 */ | ||
| 546 | "ATA-1 X3T9.2 781D rev.4" "\0" /* 0x0003 */ | ||
| 547 | "ATA-2 published, ANSI X3.279-1996" "\0" /* 0x0004 */ | ||
| 548 | "ATA-2 X3T10 948D prior to rev.2k" "\0" /* 0x0005 */ | ||
| 549 | "ATA-3 X3T10 2008D rev.1" "\0" /* 0x0006 */ | ||
| 550 | "ATA-2 X3T10 948D rev.2k" "\0" /* 0x0007 */ | ||
| 551 | "ATA-3 X3T10 2008D rev.0" "\0" /* 0x0008 */ | ||
| 552 | "ATA-2 X3T10 948D rev.3" "\0" /* 0x0009 */ | ||
| 553 | "ATA-3 published, ANSI X3.298-199x" "\0" /* 0x000a */ | ||
| 554 | "ATA-3 X3T10 2008D rev.6" "\0" /* 0x000b */ | ||
| 555 | "ATA-3 X3T13 2008D rev.7 and 7a" "\0" /* 0x000c */ | ||
| 556 | "ATA/ATAPI-4 X3T13 1153D rev.6" "\0" /* 0x000d */ | ||
| 557 | "ATA/ATAPI-4 T13 1153D rev.13" "\0" /* 0x000e */ | ||
| 558 | "ATA/ATAPI-4 X3T13 1153D rev.7" "\0" /* 0x000f */ | ||
| 559 | "ATA/ATAPI-4 T13 1153D rev.18" "\0" /* 0x0010 */ | ||
| 560 | "ATA/ATAPI-4 T13 1153D rev.15" "\0" /* 0x0011 */ | ||
| 561 | "ATA/ATAPI-4 published, ANSI INCITS 317-1998" "\0" /* 0x0012 */ | ||
| 562 | "ATA/ATAPI-5 T13 1321D rev.3" "\0" /* 0x0013 */ | ||
| 563 | "ATA/ATAPI-4 T13 1153D rev.14" "\0" /* 0x0014 */ | ||
| 564 | "ATA/ATAPI-5 T13 1321D rev.1" "\0" /* 0x0015 */ | ||
| 565 | "ATA/ATAPI-5 published, ANSI INCITS 340-2000" "\0" /* 0x0016 */ | ||
| 566 | "ATA/ATAPI-4 T13 1153D rev.17" "\0" /* 0x0017 */ | ||
| 567 | "ATA/ATAPI-6 T13 1410D rev.0" "\0" /* 0x0018 */ | ||
| 568 | "ATA/ATAPI-6 T13 1410D rev.3a" "\0" /* 0x0019 */ | ||
| 569 | "ATA/ATAPI-7 T13 1532D rev.1" "\0" /* 0x001a */ | ||
| 570 | "ATA/ATAPI-6 T13 1410D rev.2" "\0" /* 0x001b */ | ||
| 571 | "ATA/ATAPI-6 T13 1410D rev.1" "\0" /* 0x001c */ | ||
| 572 | "ATA/ATAPI-7 published, ANSI INCITS 397-2005" "\0" /* 0x001d */ | ||
| 573 | "ATA/ATAPI-7 T13 1532D rev.0" "\0" /* 0x001e */ | ||
| 574 | "reserved" "\0" /* 0x001f */ | ||
| 575 | "reserved" "\0" /* 0x0020 */ | ||
| 576 | "ATA/ATAPI-7 T13 1532D rev.4a" "\0" /* 0x0021 */ | ||
| 577 | "ATA/ATAPI-6 published, ANSI INCITS 361-2002" "\0" /* 0x0022 */ | ||
| 578 | "reserved" /* 0x0023-0xfffe */ | ||
| 579 | ; | ||
| 580 | static const char actual_ver[MINOR_MAX + 2] ALIGN1 = { | ||
| 581 | /* word 81 value: */ | ||
| 582 | 0, /* 0x0000 WARNING: actual_ver[] array */ | ||
| 583 | 1, /* 0x0001 WARNING: corresponds */ | ||
| 584 | 1, /* 0x0002 WARNING: *exactly* */ | ||
| 585 | 1, /* 0x0003 WARNING: to the ATA/ */ | ||
| 586 | 2, /* 0x0004 WARNING: ATAPI version */ | ||
| 587 | 2, /* 0x0005 WARNING: listed in */ | ||
| 588 | 3, /* 0x0006 WARNING: the */ | ||
| 589 | 2, /* 0x0007 WARNING: minor_str */ | ||
| 590 | 3, /* 0x0008 WARNING: array */ | ||
| 591 | 2, /* 0x0009 WARNING: above. */ | ||
| 592 | 3, /* 0x000a WARNING: */ | ||
| 593 | 3, /* 0x000b WARNING: If you change */ | ||
| 594 | 3, /* 0x000c WARNING: that one, */ | ||
| 595 | 4, /* 0x000d WARNING: change this one */ | ||
| 596 | 4, /* 0x000e WARNING: too!!! */ | ||
| 597 | 4, /* 0x000f */ | ||
| 598 | 4, /* 0x0010 */ | ||
| 599 | 4, /* 0x0011 */ | ||
| 600 | 4, /* 0x0012 */ | ||
| 601 | 5, /* 0x0013 */ | ||
| 602 | 4, /* 0x0014 */ | ||
| 603 | 5, /* 0x0015 */ | ||
| 604 | 5, /* 0x0016 */ | ||
| 605 | 4, /* 0x0017 */ | ||
| 606 | 6, /* 0x0018 */ | ||
| 607 | 6, /* 0x0019 */ | ||
| 608 | 7, /* 0x001a */ | ||
| 609 | 6, /* 0x001b */ | ||
| 610 | 6, /* 0x001c */ | ||
| 611 | 7, /* 0x001d */ | ||
| 612 | 7, /* 0x001e */ | ||
| 613 | 0, /* 0x001f */ | ||
| 614 | 0, /* 0x0020 */ | ||
| 615 | 7, /* 0x0021 */ | ||
| 616 | 6, /* 0x0022 */ | ||
| 617 | 0 /* 0x0023-0xfffe */ | ||
| 618 | }; | ||
| 619 | |||
| 620 | static const char cmd_feat_str[] ALIGN1 = | ||
| 621 | "" "\0" /* word 82 bit 15: obsolete */ | ||
| 622 | "NOP cmd" "\0" /* word 82 bit 14 */ | ||
| 623 | "READ BUFFER cmd" "\0" /* word 82 bit 13 */ | ||
| 624 | "WRITE BUFFER cmd" "\0" /* word 82 bit 12 */ | ||
| 625 | "" "\0" /* word 82 bit 11: obsolete */ | ||
| 626 | "Host Protected Area feature set" "\0" /* word 82 bit 10 */ | ||
| 627 | "DEVICE RESET cmd" "\0" /* word 82 bit 9 */ | ||
| 628 | "SERVICE interrupt" "\0" /* word 82 bit 8 */ | ||
| 629 | "Release interrupt" "\0" /* word 82 bit 7 */ | ||
| 630 | "Look-ahead" "\0" /* word 82 bit 6 */ | ||
| 631 | "Write cache" "\0" /* word 82 bit 5 */ | ||
| 632 | "PACKET command feature set" "\0" /* word 82 bit 4 */ | ||
| 633 | "Power Management feature set" "\0" /* word 82 bit 3 */ | ||
| 634 | "Removable Media feature set" "\0" /* word 82 bit 2 */ | ||
| 635 | "Security Mode feature set" "\0" /* word 82 bit 1 */ | ||
| 636 | "SMART feature set" "\0" /* word 82 bit 0 */ | ||
| 637 | /* -------------- */ | ||
| 638 | "" "\0" /* word 83 bit 15: !valid bit */ | ||
| 639 | "" "\0" /* word 83 bit 14: valid bit */ | ||
| 640 | "FLUSH CACHE EXT cmd" "\0" /* word 83 bit 13 */ | ||
| 641 | "Mandatory FLUSH CACHE cmd " "\0" /* word 83 bit 12 */ | ||
| 642 | "Device Configuration Overlay feature set " "\0" | ||
| 643 | "48-bit Address feature set " "\0" /* word 83 bit 10 */ | ||
| 644 | "" "\0" | ||
| 645 | "SET MAX security extension" "\0" /* word 83 bit 8 */ | ||
| 646 | "Address Offset Reserved Area Boot" "\0" /* word 83 bit 7 */ | ||
| 647 | "SET FEATURES subcommand required to spinup after power up" "\0" | ||
| 648 | "Power-Up In Standby feature set" "\0" /* word 83 bit 5 */ | ||
| 649 | "Removable Media Status Notification feature set" "\0" | ||
| 650 | "Adv. Power Management feature set" "\0" /* word 83 bit 3 */ | ||
| 651 | "CFA feature set" "\0" /* word 83 bit 2 */ | ||
| 652 | "READ/WRITE DMA QUEUED" "\0" /* word 83 bit 1 */ | ||
| 653 | "DOWNLOAD MICROCODE cmd" "\0" /* word 83 bit 0 */ | ||
| 654 | /* -------------- */ | ||
| 655 | "" "\0" /* word 84 bit 15: !valid bit */ | ||
| 656 | "" "\0" /* word 84 bit 14: valid bit */ | ||
| 657 | "" "\0" /* word 84 bit 13: reserved */ | ||
| 658 | "" "\0" /* word 84 bit 12: reserved */ | ||
| 659 | "" "\0" /* word 84 bit 11: reserved */ | ||
| 660 | "" "\0" /* word 84 bit 10: reserved */ | ||
| 661 | "" "\0" /* word 84 bit 9: reserved */ | ||
| 662 | "" "\0" /* word 84 bit 8: reserved */ | ||
| 663 | "" "\0" /* word 84 bit 7: reserved */ | ||
| 664 | "" "\0" /* word 84 bit 6: reserved */ | ||
| 665 | "General Purpose Logging feature set" "\0" /* word 84 bit 5 */ | ||
| 666 | "" "\0" /* word 84 bit 4: reserved */ | ||
| 667 | "Media Card Pass Through Command feature set " "\0" | ||
| 668 | "Media serial number " "\0" /* word 84 bit 2 */ | ||
| 669 | "SMART self-test " "\0" /* word 84 bit 1 */ | ||
| 670 | "SMART error logging " /* word 84 bit 0 */ | ||
| 671 | ; | ||
| 672 | |||
| 673 | static const char secu_str[] ALIGN1 = | ||
| 674 | "supported" "\0" /* word 128, bit 0 */ | ||
| 675 | "enabled" "\0" /* word 128, bit 1 */ | ||
| 676 | "locked" "\0" /* word 128, bit 2 */ | ||
| 677 | "frozen" "\0" /* word 128, bit 3 */ | ||
| 678 | "expired: security count" "\0" /* word 128, bit 4 */ | ||
| 679 | "supported: enhanced erase" /* word 128, bit 5 */ | ||
| 680 | ; | ||
| 681 | |||
| 682 | // Parse 512 byte disk identification block and print much crap. | ||
| 699 | static void identify(uint16_t *val) ATTRIBUTE_NORETURN; | 683 | static void identify(uint16_t *val) ATTRIBUTE_NORETURN; |
| 700 | static void identify(uint16_t *val) | 684 | static void identify(uint16_t *val) |
| 701 | { | 685 | { |
| @@ -726,10 +710,10 @@ static void identify(uint16_t *val) | |||
| 726 | } else if (!(val[GEN_CONFIG] & NOT_ATAPI)) { | 710 | } else if (!(val[GEN_CONFIG] & NOT_ATAPI)) { |
| 727 | dev = ATAPI_DEV; | 711 | dev = ATAPI_DEV; |
| 728 | eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT; | 712 | eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT; |
| 729 | printf("ATAPI %s, with ", pkt_str[eqpt]); | 713 | printf("ATAPI %s, with ", eqpt <= 0xf ? nth_str(pkt_str, eqpt) : "unknown"); |
| 730 | like_std = 3; | 714 | like_std = 3; |
| 731 | } else | 715 | } else |
| 732 | /*"Unknown device type:\n\tbits 15&14 of general configuration word 0 both set to 1.\n"*/ | 716 | /* "Unknown device type:\n\tbits 15&14 of general configuration word 0 both set to 1.\n" */ |
| 733 | bb_error_msg_and_die("unknown device type"); | 717 | bb_error_msg_and_die("unknown device type"); |
| 734 | 718 | ||
| 735 | printf("%sremovable media\n", !(val[GEN_CONFIG] & MEDIA_REMOVABLE) ? "non-" : ""); | 719 | printf("%sremovable media\n", !(val[GEN_CONFIG] & MEDIA_REMOVABLE) ? "non-" : ""); |
| @@ -764,7 +748,7 @@ static void identify(uint16_t *val) | |||
| 764 | if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) { | 748 | if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) { |
| 765 | if (like_std < 3) like_std = 3; | 749 | if (like_std < 3) like_std = 3; |
| 766 | std = actual_ver[val[MINOR]]; | 750 | std = actual_ver[val[MINOR]]; |
| 767 | if (std) printf("\n\tUsed: %s ", minor_str[val[MINOR]]); | 751 | if (std) printf("\n\tUsed: %s ", nth_str(minor_str, val[MINOR])); |
| 768 | 752 | ||
| 769 | } | 753 | } |
| 770 | /* looks like when they up-issue the std, they obsolete one; | 754 | /* looks like when they up-issue the std, they obsolete one; |
| @@ -863,7 +847,7 @@ static void identify(uint16_t *val) | |||
| 863 | jj = val[GEN_CONFIG] >> 1; | 847 | jj = val[GEN_CONFIG] >> 1; |
| 864 | for (ii = 1; ii < 15; ii++) { | 848 | for (ii = 1; ii < 15; ii++) { |
| 865 | if (jj & 0x0001) | 849 | if (jj & 0x0001) |
| 866 | printf("\t%s\n", ata1_cfg_str[ii]); | 850 | printf("\t%s\n", nth_str(ata1_cfg_str, ii)); |
| 867 | jj >>=1; | 851 | jj >>=1; |
| 868 | } | 852 | } |
| 869 | } | 853 | } |
| @@ -875,7 +859,7 @@ static void identify(uint16_t *val) | |||
| 875 | else if ((val[GEN_CONFIG] & DRQ_RESPONSE_TIME) == DRQ_50US_VAL) | 859 | else if ((val[GEN_CONFIG] & DRQ_RESPONSE_TIME) == DRQ_50US_VAL) |
| 876 | strng ="50us"; | 860 | strng ="50us"; |
| 877 | else | 861 | else |
| 878 | strng = "Unknown"; | 862 | strng = "unknown"; |
| 879 | printf("\tDRQ response: %s\n\tPacket size: ", strng); /* Data Request (DRQ) */ | 863 | printf("\tDRQ response: %s\n\tPacket size: ", strng); /* Data Request (DRQ) */ |
| 880 | 864 | ||
| 881 | if ((val[GEN_CONFIG] & PKT_SIZE_SUPPORTED) == PKT_SIZE_12_VAL) | 865 | if ((val[GEN_CONFIG] & PKT_SIZE_SUPPORTED) == PKT_SIZE_12_VAL) |
| @@ -883,7 +867,7 @@ static void identify(uint16_t *val) | |||
| 883 | else if ((val[GEN_CONFIG] & PKT_SIZE_SUPPORTED) == PKT_SIZE_16_VAL) | 867 | else if ((val[GEN_CONFIG] & PKT_SIZE_SUPPORTED) == PKT_SIZE_16_VAL) |
| 884 | strng = "16 bytes"; | 868 | strng = "16 bytes"; |
| 885 | else | 869 | else |
| 886 | strng = "Unknown"; | 870 | strng = "unknown"; |
| 887 | puts(strng); | 871 | puts(strng); |
| 888 | } else { | 872 | } else { |
| 889 | /* addressing...CHS? See section 6.2 of ATA specs 4 or 5 */ | 873 | /* addressing...CHS? See section 6.2 of ATA specs 4 or 5 */ |
| @@ -1070,7 +1054,7 @@ static void identify(uint16_t *val) | |||
| 1070 | printf("pio%d ", ii); | 1054 | printf("pio%d ", ii); |
| 1071 | bb_putchar('\n'); | 1055 | bb_putchar('\n'); |
| 1072 | } else | 1056 | } else |
| 1073 | printf("unknown\n"); | 1057 | puts("unknown"); |
| 1074 | 1058 | ||
| 1075 | if (val[WHATS_VALID] & OK_W64_70) { | 1059 | if (val[WHATS_VALID] & OK_W64_70) { |
| 1076 | if (val[PIO_NO_FLOW] || val[PIO_FLOW]) { | 1060 | if (val[PIO_NO_FLOW] || val[PIO_FLOW]) { |
| @@ -1086,8 +1070,9 @@ static void identify(uint16_t *val) | |||
| 1086 | jj = val[CMDS_SUPP_0]; | 1070 | jj = val[CMDS_SUPP_0]; |
| 1087 | kk = val[CMDS_EN_0]; | 1071 | kk = val[CMDS_EN_0]; |
| 1088 | for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) { | 1072 | for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) { |
| 1089 | if ((jj & 0x8000) && (*cmd_feat_str[ii] != '\0')) { | 1073 | const char *feat_str = nth_str(cmd_feat_str, ii); |
| 1090 | printf("\t%s\t%s\n", (kk & 0x8000) ? " *" : "", cmd_feat_str[ii]); | 1074 | if ((jj & 0x8000) && (*feat_str != '\0')) { |
| 1075 | printf("\t%s\t%s\n", (kk & 0x8000) ? " *" : "", feat_str); | ||
| 1091 | } | 1076 | } |
| 1092 | jj <<= 1; | 1077 | jj <<= 1; |
| 1093 | kk <<= 1; | 1078 | kk <<= 1; |
| @@ -1103,7 +1088,7 @@ static void identify(uint16_t *val) | |||
| 1103 | } | 1088 | } |
| 1104 | /* Removable Media Status Notification feature set */ | 1089 | /* Removable Media Status Notification feature set */ |
| 1105 | if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP) | 1090 | if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP) |
| 1106 | printf("\t%s supported\n", cmd_feat_str[27]); | 1091 | printf("\t%s supported\n", nth_str(cmd_feat_str, 27)); |
| 1107 | 1092 | ||
| 1108 | /* security */ | 1093 | /* security */ |
| 1109 | if ((eqpt != CDROM) && (like_std > 3) | 1094 | if ((eqpt != CDROM) && (like_std > 3) |
| @@ -1115,7 +1100,7 @@ static void identify(uint16_t *val) | |||
| 1115 | jj = val[SECU_STATUS]; | 1100 | jj = val[SECU_STATUS]; |
| 1116 | if (jj) { | 1101 | if (jj) { |
| 1117 | for (ii = 0; ii < NUM_SECU_STR; ii++) { | 1102 | for (ii = 0; ii < NUM_SECU_STR; ii++) { |
| 1118 | printf("\t%s\t%s\n", (!(jj & 0x0001)) ? "not" : "", secu_str[ii]); | 1103 | printf("\t%s\t%s\n", (!(jj & 0x0001)) ? "not" : "", nth_str(secu_str, ii)); |
| 1119 | jj >>=1; | 1104 | jj >>=1; |
| 1120 | } | 1105 | } |
| 1121 | if (val[SECU_STATUS] & SECU_ENABLED) { | 1106 | if (val[SECU_STATUS] & SECU_ENABLED) { |
| @@ -1177,16 +1162,16 @@ static void identify(uint16_t *val) | |||
| 1177 | // Too bad, really. | 1162 | // Too bad, really. |
| 1178 | 1163 | ||
| 1179 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY | 1164 | #if ENABLE_FEATURE_HDPARM_GET_IDENTITY |
| 1180 | static const char *const cfg_str[] = { | 1165 | static const char cfg_str[] ALIGN1 = |
| 1181 | "", "HardSect", "SoftSect", "NotMFM", | 1166 | """\0" "HardSect""\0" "SoftSect""\0" "NotMFM""\0" |
| 1182 | "HdSw>15uSec", "SpinMotCtl", "Fixed", "Removeable", | 1167 | "HdSw>15uSec""\0" "SpinMotCtl""\0" "Fixed""\0" "Removeable""\0" |
| 1183 | "DTR<=5Mbs", "DTR>5Mbs", "DTR>10Mbs", "RotSpdTol>.5%", | 1168 | "DTR<=5Mbs""\0" "DTR>5Mbs""\0" "DTR>10Mbs""\0" "RotSpdTol>.5%""\0" |
| 1184 | "dStbOff", "TrkOff", "FmtGapReq", "nonMagnetic" | 1169 | "dStbOff""\0" "TrkOff""\0" "FmtGapReq""\0" "nonMagnetic" |
| 1185 | }; | 1170 | ; |
| 1186 | 1171 | ||
| 1187 | static const char *const BuffType[] = { | 1172 | static const char BuffType[] ALIGN1 = |
| 1188 | "Unknown", "1Sect", "DualPort", "DualPortCache" | 1173 | "unknown""\0" "1Sect""\0" "DualPort""\0" "DualPortCache" |
| 1189 | }; | 1174 | ; |
| 1190 | 1175 | ||
| 1191 | static void dump_identity(const struct hd_driveid *id) | 1176 | static void dump_identity(const struct hd_driveid *id) |
| 1192 | { | 1177 | { |
| @@ -1197,13 +1182,13 @@ static void dump_identity(const struct hd_driveid *id) | |||
| 1197 | id->model, id->fw_rev, id->serial_no); | 1182 | id->model, id->fw_rev, id->serial_no); |
| 1198 | for (i = 0; i <= 15; i++) { | 1183 | for (i = 0; i <= 15; i++) { |
| 1199 | if (id->config & (1<<i)) | 1184 | if (id->config & (1<<i)) |
| 1200 | printf(" %s", cfg_str[i]); | 1185 | printf(" %s", nth_str(cfg_str, i)); |
| 1201 | } | 1186 | } |
| 1202 | printf(" }\n RawCHS=%u/%u/%u, TrkSize=%u, SectSize=%u, ECCbytes=%u\n" | 1187 | printf(" }\n RawCHS=%u/%u/%u, TrkSize=%u, SectSize=%u, ECCbytes=%u\n" |
| 1203 | " BuffType=(%u) %s, BuffSize=%ukB, MaxMultSect=%u", | 1188 | " BuffType=(%u) %s, BuffSize=%ukB, MaxMultSect=%u", |
| 1204 | id->cyls, id->heads, id->sectors, id->track_bytes, | 1189 | id->cyls, id->heads, id->sectors, id->track_bytes, |
| 1205 | id->sector_bytes, id->ecc_bytes, | 1190 | id->sector_bytes, id->ecc_bytes, |
| 1206 | id->buf_type, BuffType[(id->buf_type > 3) ? 0 : id->buf_type], | 1191 | id->buf_type, nth_str(BuffType, (id->buf_type > 3) ? 0 : id->buf_type), |
| 1207 | id->buf_size/2, id->max_multsect); | 1192 | id->buf_size/2, id->max_multsect); |
| 1208 | if (id->max_multsect) { | 1193 | if (id->max_multsect) { |
| 1209 | printf(", MultSect="); | 1194 | printf(", MultSect="); |
| @@ -1309,7 +1294,7 @@ static void dump_identity(const struct hd_driveid *id) | |||
| 1309 | if ((id->minor_rev_num && id->minor_rev_num <= 31) | 1294 | if ((id->minor_rev_num && id->minor_rev_num <= 31) |
| 1310 | || (id->major_rev_num && id->minor_rev_num <= 31) | 1295 | || (id->major_rev_num && id->minor_rev_num <= 31) |
| 1311 | ) { | 1296 | ) { |
| 1312 | printf("\n Drive conforms to: %s: ", (id->minor_rev_num <= 31) ? minor_str[id->minor_rev_num] : "Unknown"); | 1297 | printf("\n Drive conforms to: %s: ", (id->minor_rev_num <= 31) ? nth_str(minor_str, id->minor_rev_num) : "unknown"); |
| 1313 | if (id->major_rev_num != 0x0000 && /* NOVAL_0 */ | 1298 | if (id->major_rev_num != 0x0000 && /* NOVAL_0 */ |
| 1314 | id->major_rev_num != 0xFFFF) { /* NOVAL_1 */ | 1299 | id->major_rev_num != 0xFFFF) { /* NOVAL_1 */ |
| 1315 | for (i = 0; i <= 15; i++) { | 1300 | for (i = 0; i <= 15; i++) { |
| @@ -1479,7 +1464,7 @@ static void interpret_standby(unsigned standby) | |||
| 1479 | else if (standby == 253) | 1464 | else if (standby == 253) |
| 1480 | printf("vendor-specific"); | 1465 | printf("vendor-specific"); |
| 1481 | else if (standby == 254) | 1466 | else if (standby == 254) |
| 1482 | printf("Reserved"); | 1467 | printf("reserved"); |
| 1483 | else if (standby == 255) | 1468 | else if (standby == 255) |
| 1484 | printf("21 minutes + 15 seconds"); | 1469 | printf("21 minutes + 15 seconds"); |
| 1485 | else if (standby <= 240) { | 1470 | else if (standby <= 240) { |
| @@ -1539,7 +1524,7 @@ static void interpret_xfermode(unsigned xfermode) | |||
| 1539 | else if (xfermode >= 64 && xfermode <= 71) | 1524 | else if (xfermode >= 64 && xfermode <= 71) |
| 1540 | printf("UltraDMA mode%u", xfermode - 64); | 1525 | printf("UltraDMA mode%u", xfermode - 64); |
| 1541 | else | 1526 | else |
| 1542 | printf("Unknown"); | 1527 | printf("unknown"); |
| 1543 | printf(")\n"); | 1528 | printf(")\n"); |
| 1544 | } | 1529 | } |
| 1545 | #endif /* HDIO_DRIVE_CMD */ | 1530 | #endif /* HDIO_DRIVE_CMD */ |
