Changeset 76 for hacks/xtide/ataid.c
- Timestamp:
- Dec 28, 2015, 2:37:00 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
hacks/xtide/ataid.c
r75 r76 45 45 46 46 47 static void AtaPrintIdString(const char *pszPrefix, uint16_t const *pawStr, unsigned cWords, const char *pszSuffix) 48 { 49 unsigned i; 50 51 fputs(pszPrefix, stdout); 52 53 putchar('\''); 54 for (i = 0; i < cWords; i++) 55 { 56 int j; 57 for (j = 8; j >= 0; j -= 8) 58 { 59 uint8_t b = (uint8_t)(pawStr[i] >> j); 60 if (b < UINT8_C(0x7f) || b >= UINT8_C(0x20)) 61 putchar(b); 62 else 63 printf("\\x%02x", b); 64 } 65 } 66 putchar('\''); 67 68 fputs(pszSuffix, stdout); 69 } 70 71 47 72 int main(int argc, char **argv) 48 73 { … … 59 84 */ 60 85 /* Word[0]: */ 61 printf("[0]=%#06x", g_awIdentify[0]); 62 if ((g_awIdentify[0] >> 7) & 1) 63 fputs(" removable-media", stdout); 64 if ((g_awIdentify[0] >> 6) & 1) 65 fputs(" not-removable", stdout); 66 if ((g_awIdentify[0] >> 2) & 1) 67 fputs(" bit2-maybe-incomplete!", stdout); 68 if ((g_awIdentify[0] >> 15) & 1) 69 fputs(" not-ATA-device!", stdout); 70 putchar('\n'); 71 72 printf("[ 1]=%#06x - obsolete logical cylinders %d\n", g_awIdentify[1], g_awIdentify[1]); 73 printf("[ 2]=%#06x (reserved / vendor specific)\n", g_awIdentify[2]); 74 printf("[ 3]=%#06x - obsolete logical heads %d\n", g_awIdentify[3], g_awIdentify[3]); 75 printf("[ 4]=%#06x - vendor specific / retired\n", g_awIdentify[4]); 76 printf("[ 5]=%#06x - vendor specific / retired\n", g_awIdentify[5]); 77 printf("[ 6]=%#06x - obsolete logical sectors per track %d\n", g_awIdentify[6], g_awIdentify[6]); 78 printf("[ 7]=%#06x - vendor specific / reserved for CompactFlash\n", g_awIdentify[7]); 79 printf("[ 8]=%#06x - vendor specific / reserved for CompactFlash\n", g_awIdentify[8]); 80 printf("[ 9]=%#06x - vendor specific / retired\n", g_awIdentify[9]); 81 printf("[ 10:19] - serial number '%.20s'\n", &g_awIdentify[10]); 82 printf("[ 20]=%#06x - vendor specific / obsolete\n", g_awIdentify[20]); 83 printf("[ 21]=%#06x - vendor specific / obsolete\n", g_awIdentify[21]); 84 printf("[ 22]=%#06x - obsolete ECC/vendor bytes for READ/WRITE LONG %d\n", g_awIdentify[22], g_awIdentify[22]); 85 printf("[ 23:26] - firmware revision '%.8s'\n", &g_awIdentify[23]); 86 printf("[ 27:46] - model number '%.40s'\n", &g_awIdentify[27]); 87 88 printf("[ 47]=%#06x - READ/WRITE MULTIPLE ", g_awIdentify[47]); 89 if ((g_awIdentify[47] & 0xff) == 0) 86 i = 0; 87 printf("[%3u]=%#06x", i, g_awIdentify[i]); 88 if ((g_awIdentify[i] >> 7) & 1) fputs(" removable-media", stdout); 89 if ((g_awIdentify[i] >> 6) & 1) fputs(" not-removable", stdout); 90 if ((g_awIdentify[i] >> 2) & 1) fputs(" bit2-maybe-incomplete!", stdout); 91 if ((g_awIdentify[i] >> 15) & 1) fputs(" not-ATA-device!", stdout); 92 putchar('\n'); 93 94 i = 1; printf("[%3u]=%#06x - obsolete logical cylinders: %d\n", i, g_awIdentify[i], g_awIdentify[i]); 95 i = 2; printf("[%3u]=%#06x (reserved / vendor specific)\n", i, g_awIdentify[i]); 96 i = 3; printf("[%3u]=%#06x - obsolete logical heads: %d\n", i, g_awIdentify[i], g_awIdentify[i]); 97 i = 4; printf("[%3u]=%#06x (vendor specific / retired)\n", i, g_awIdentify[i]); 98 i = 5; printf("[%3u]=%#06x (vendor specific / retired)\n", i, g_awIdentify[i]); 99 i = 6; printf("[%3u]=%#06x - obsolete logical sectors per track: %d\n", i, g_awIdentify[i], g_awIdentify[i]); 100 i = 7; printf("[%3u]=%#06x (vendor specific / reserved for CompactFlash)\n", i, g_awIdentify[i]); 101 i = 8; printf("[%3u]=%#06x (vendor specific / reserved for CompactFlash)\n", i, g_awIdentify[i]); 102 i = 9; printf("[%3u]=%#06x (vendor specific / retired)\n", i, g_awIdentify[i]); 103 i = 10; AtaPrintIdString("[ 10:19] - serial number: ", &g_awIdentify[i], 10, "\n"); 104 i = 20; printf("[%3u]=%#06x (vendor specific / obsolete)\n", i, g_awIdentify[i]); 105 i = 21; printf("[%3u=%#06x (vendor specific / obsolete)\n", i, g_awIdentify[i]); 106 i = 22; printf("[=%#06x - obsolete ECC/vendor bytes for READ/WRITE LONG %d\n", i, g_awIdentify[i], g_awIdentify[i]); 107 i = 23; AtaPrintIdString("[ 23:26] - firmware revision: ", &g_awIdentify[i], 4, "\n"); 108 i = 27; AtaPrintIdString("[ 27:46] - model number: ", &g_awIdentify[i], 20, "\n"); 109 110 i = 47; printf("[%3u]=%#06x - READ/WRITE MULTIPLE ", i, g_awIdentify[i]); 111 if ((g_awIdentify[i] & 0xff) == 0) 90 112 fputs("not implemented", stdout); 91 else if ((g_awIdentify[47] & 0xff) == 0)113 else 92 114 printf("max %d sectors", g_awIdentify[47] & 0xff); 93 if ((g_awIdentify[ 47] >> 8) == 0x80)115 if ((g_awIdentify[i] >> 8) == 0x80) 94 116 fputs(", ATA-4 top value", stdout); 95 117 else … … 97 119 putchar('\n'); 98 120 99 printf("[ 48]=%#06x - trusted computing group bits ", g_awIdentify[48]);100 if ((g_awIdentify[ 48] & UINT16_C(0xc001)) == UINT16_C(0x4001))101 printf("%#x\n", g_awIdentify[ 48] & UINT16_C(0x3ffe));121 i = 48; printf("[%3u]=%#06x - trusted computing group bits ", i, g_awIdentify[i]); 122 if ((g_awIdentify[i] & UINT16_C(0xc001)) == UINT16_C(0x4001)) 123 printf("%#x\n", g_awIdentify[i] & UINT16_C(0x3ffe)); 102 124 else 103 125 fputs("not present\n", stdout); 104 126 105 printf("[ 49]=%#06x - capabilities:", g_awIdentify[49]); 106 if (g_awIdentify[49] & UINT16_C(0x0100)) 107 fputs(" DMA", stdout); 108 if (g_awIdentify[49] & UINT16_C(0x0200)) 109 fputs(" LBA", stdout); 110 if (g_awIdentify[49] & UINT16_C(0x0400)) 111 fputs(" IORDY-disable", stdout); 112 if (g_awIdentify[49] & UINT16_C(0x0800)) 113 fputs(" IORDY-supported", stdout); 114 if (g_awIdentify[49] & UINT16_C(0x1000)) 115 fputs(" rsvd12", stdout); 116 if (g_awIdentify[49] & UINT16_C(0x2000)) 117 fputs(" ata2-standby-timer", stdout); 118 if (g_awIdentify[49] & UINT16_C(0x4000)) 119 fputs(" rsvd14", stdout); 120 if (g_awIdentify[49] & UINT16_C(0x8000)) 121 fputs(" rsvd15", stdout); 122 if (g_awIdentify[49] & UINT16_C(0x00ff)) 123 printf(" vendor07=%#x", g_awIdentify[49] & UINT16_C(0x00ff)); 124 putchar('\n'); 125 126 printf("[ 50]=%#06x - capabilities:", g_awIdentify[50]); 127 if ((g_awIdentify[50] & UINT16_C(0xc000)) == UINT16_C(0x4000)) 128 { 129 if (g_awIdentify[50] & 1) 130 fputs(" vendor-standby-timer-min", stdout); 131 if (g_awIdentify[50] & 2) 132 fputs(" obsolete1", stdout); 133 if (g_awIdentify[50] & UINT16_C(0x3ffc)) 134 printf(" reserved=%#x", g_awIdentify[50] & UINT16_C(0x3ffc)); 127 i = 49; printf("[%3u]=%#06x - capabilities:", i, g_awIdentify[i]); 128 if (g_awIdentify[i] & UINT16_C(0x0100)) fputs(" DMA", stdout); 129 if (g_awIdentify[i] & UINT16_C(0x0200)) fputs(" LBA", stdout); 130 if (g_awIdentify[i] & UINT16_C(0x0400)) fputs(" IORDY-disable", stdout); 131 if (g_awIdentify[i] & UINT16_C(0x0800)) fputs(" IORDY-supported", stdout); 132 if (g_awIdentify[i] & UINT16_C(0x1000)) fputs(" rsvd12", stdout); 133 if (g_awIdentify[i] & UINT16_C(0x2000)) fputs(" ata2-standby-timer", stdout); 134 if (g_awIdentify[i] & UINT16_C(0x4000)) fputs(" rsvd14", stdout); 135 if (g_awIdentify[i] & UINT16_C(0x8000)) fputs(" rsvd15", stdout); 136 if (g_awIdentify[i] & UINT16_C(0x00ff)) printf(" vendor07=%#x", g_awIdentify[i] & UINT16_C(0x00ff)); 137 putchar('\n'); 138 139 i = 50; printf("[%3u]=%#06x - capabilities:", i, g_awIdentify[i]); 140 if ((g_awIdentify[i] & UINT16_C(0xc000)) == UINT16_C(0x4000)) 141 { 142 if (g_awIdentify[i] & 1) fputs(" vendor-standby-timer-min", stdout); 143 if (g_awIdentify[i] & 2) fputs(" obsolete1", stdout); 144 if (g_awIdentify[i] & UINT16_C(0x3ffc)) printf(" reserved=%#x", g_awIdentify[i] & UINT16_C(0x3ffc)); 135 145 putchar('\n'); 136 146 } … … 161 171 printf(" free-fall-sensitivity=%#x\n", g_awIdentify[53] >> 8); 162 172 163 printf("[ 54]=%#06x - obsolete current logical cylinders %d", g_awIdentify[54]);173 i = 54; printf("[%3u]=%#06x - obsolete current logical cylinders %d", i, g_awIdentify[i], g_awIdentify[i]); 164 174 if (g_awIdentify[54] > 16383) 165 175 fputs(" (high!)", stdout); 166 176 putchar('\n'); 167 177 168 printf("[ 55]=%#06x - obsolete current logical heads %d", g_awIdentify[55]);178 i = 55; printf("[%3u]=%#06x - obsolete current logical heads %d", i, g_awIdentify[i], g_awIdentify[i]); 169 179 if (g_awIdentify[55] > 16) 170 180 fputs(" (high!)", stdout); 171 181 putchar('\n'); 172 182 173 printf("[ 56]=%#06x - obsolete current logical sectors per track %d", g_awIdentify[56]);183 i = 56; printf("[%3u]=%#06x - obsolete current logical sectors per track %d", i, g_awIdentify[i], g_awIdentify[i]); 174 184 if (g_awIdentify[56] > 63) 175 185 fputs(" (high!)", stdout); … … 229 239 printf("[ 67]=%#06x - minimum PIO cycle time without IORDY %d ns\n", g_awIdentify[67], g_awIdentify[67]); 230 240 printf("[ 68]=%#06x - minimum PIO cycle time with IORDY %d ns\n", g_awIdentify[68], g_awIdentify[68]); 231 printf("[ 69]=%#06x - reserved\n", g_awIdentify[69]);232 printf("[ 70]=%#06x - reserved\n", g_awIdentify[70]);233 printf("[ 71]=%#06x - reserved for identify packet device\n", g_awIdentify[71]);234 printf("[ 72]=%#06x - reserved for identify packet device\n", g_awIdentify[72]);235 printf("[ 73]=%#06x - reserved for identify packet device\n", g_awIdentify[73]);236 printf("[ 74]=%#06x - reserved for identify packet device\n", g_awIdentify[74]);241 printf("[ 69]=%#06x (reserved)\n", g_awIdentify[69]); 242 printf("[ 70]=%#06x (reserved)\n", g_awIdentify[70]); 243 printf("[ 71]=%#06x (reserved for identify packet device)\n", g_awIdentify[71]); 244 printf("[ 72]=%#06x (reserved for identify packet device)\n", g_awIdentify[72]); 245 printf("[ 73]=%#06x (reserved for identify packet device)\n", g_awIdentify[73]); 246 printf("[ 74]=%#06x (reserved for identify packet device)\n", g_awIdentify[74]); 237 247 238 248 printf("[ 75]=%#06x - queue depth %d", g_awIdentify[75], (g_awIdentify[75] & 0x1f) + 1); … … 263 273 fputs(" probably not SATA\n", stdout); 264 274 265 printf("[ 77]=%#06x - reserved for SATA\n", g_awIdentify[77]);275 printf("[ 77]=%#06x (reserved for SATA)\n", g_awIdentify[77]); 266 276 267 277 printf("[ 78]=%#06x - SATA features supported: ", g_awIdentify[78]); … … 315 325 if (g_awIdentify[80] & (UINT16_C(0x0001) << i)) 316 326 printf(" ata%u", i); 327 putchar('\n'); 317 328 } 318 329 else 319 330 fputs(" not specified\n", stdout); 320 331 321 printf("[ 81]=%#06x - Minor version number: %d ", g_awIdentify[81], g_awIdentify[81]);332 printf("[ 81]=%#06x - Minor version number: %d\n", g_awIdentify[81], g_awIdentify[81]); 322 333 323 334 printf("[ 82]=%#06x - Supports: ", g_awIdentify[82]); 324 if (g_awIdentify[82] & UINT16_C(0x0001)) fputs(" smart", stdout); 325 if (g_awIdentify[82] & UINT16_C(0x0002)) fputs(" security", stdout); 326 if (g_awIdentify[82] & UINT16_C(0x0004)) fputs(" obsolete2", stdout); 327 if (g_awIdentify[82] & UINT16_C(0x0008)) fputs(" mand-power-management", stdout); 328 if (!(g_awIdentify[82] & UINT16_C(0x0010))) fputs(" no-packet", stdout); 329 if (g_awIdentify[82] & UINT16_C(0x0020)) fputs(" volatile-write-cache", stdout); 330 if (g_awIdentify[82] & UINT16_C(0x0040)) fputs(" look-ahead", stdout); 331 if (g_awIdentify[82] & UINT16_C(0x0080)) fputs(" release-intr", stdout); 332 if (g_awIdentify[82] & UINT16_C(0x0100)) fputs(" service-intr", stdout); 333 if (!(g_awIdentify[82] & UINT16_C(0x0200))) fputs(" no-device-reset", stdout); 334 if (g_awIdentify[82] & UINT16_C(0x0400)) fputs(" hpa", stdout); 335 if (g_awIdentify[82] & UINT16_C(0x0800)) fputs(" obsolete11", stdout); 336 if (g_awIdentify[82] & UINT16_C(0x1000)) fputs(" write-buffer", stdout); 337 if (g_awIdentify[82] & UINT16_C(0x2000)) fputs(" read-buffer", stdout); 338 if (g_awIdentify[82] & UINT16_C(0x4000)) fputs(" nop", stdout); 339 if (g_awIdentify[82] & UINT16_C(0x8000)) fputs(" obsolete15", stdout); 340 putchar('\n'); 335 if ((g_awIdentify[83] & UINT16_C(0xc000)) == UINT16_C(0x4000)) /* yes, 83; see 7.16.7.38 in ata8. */ 336 { 337 if (g_awIdentify[82] & UINT16_C(0x0001)) fputs(" smart", stdout); 338 if (g_awIdentify[82] & UINT16_C(0x0002)) fputs(" security", stdout); 339 if (g_awIdentify[82] & UINT16_C(0x0004)) fputs(" obsolete2", stdout); 340 if (g_awIdentify[82] & UINT16_C(0x0008)) fputs(" mand-power-management", stdout); 341 if (!(g_awIdentify[82] & UINT16_C(0x0010))) fputs(" no-packet", stdout); 342 if (g_awIdentify[82] & UINT16_C(0x0020)) fputs(" volatile-write-cache", stdout); 343 if (g_awIdentify[82] & UINT16_C(0x0040)) fputs(" look-ahead", stdout); 344 if (g_awIdentify[82] & UINT16_C(0x0080)) fputs(" release-intr", stdout); 345 if (g_awIdentify[82] & UINT16_C(0x0100)) fputs(" service-intr", stdout); 346 if (!(g_awIdentify[82] & UINT16_C(0x0200))) fputs(" no-device-reset", stdout); 347 if (g_awIdentify[82] & UINT16_C(0x0400)) fputs(" hpa", stdout); 348 if (g_awIdentify[82] & UINT16_C(0x0800)) fputs(" obsolete11", stdout); 349 if (g_awIdentify[82] & UINT16_C(0x1000)) fputs(" write-buffer", stdout); 350 if (g_awIdentify[82] & UINT16_C(0x2000)) fputs(" read-buffer", stdout); 351 if (g_awIdentify[82] & UINT16_C(0x4000)) fputs(" nop", stdout); 352 if (g_awIdentify[82] & UINT16_C(0x8000)) fputs(" obsolete15", stdout); 353 putchar('\n'); 354 } 355 else 356 fputs(" not specified\n", stdout); 341 357 342 358 printf("[ 83]=%#06x - Supports: ", g_awIdentify[83]); … … 470 486 printf("[ 92]=%#06x - master password ID: %d\n", g_awIdentify[92], g_awIdentify[92]); 471 487 472 printf("[ 93]=%#06x - hardware reset result:", g_awIdentify[9 2], g_awIdentify[92]);488 printf("[ 93]=%#06x - hardware reset result:", g_awIdentify[93], g_awIdentify[93]); 473 489 if ((g_awIdentify[93] & UINT16_C(0xc000)) == UINT16_C(0x4000)) 474 490 { … … 509 525 *(uint64_t *)&g_awIdentify[100], *(uint64_t *)&g_awIdentify[100]); 510 526 printf("[104]=%#06x - streaming transfer time, PIO: %d\n", g_awIdentify[104], g_awIdentify[104]); 511 printf("[105]=%#06x - reserved\n", g_awIdentify[105]);527 printf("[105]=%#06x (reserved)\n", g_awIdentify[105]); 512 528 if ((g_awIdentify[106] & UINT16_C(0xc000)) == UINT16_C(0x4000)) 513 529 { … … 523 539 524 540 printf("[107]=%#06x - Inter-seek delay for acoustic testing\n", g_awIdentify[107]); 525 printf("[108:111] - World wide name: %#llx\n", *(uint64_t *)&g_awIdentify[10 7]);541 printf("[108:111] - World wide name: %#llx\n", *(uint64_t *)&g_awIdentify[108]); 526 542 for (i = 112; i <= 116; i++) 527 printf("[%u]=%#06x - reserved\n", i, g_awIdentify[i]);543 printf("[%u]=%#06x (reserved)\n", i, g_awIdentify[i]); 528 544 printf("[117:118] - Logical sector size: %lu bytes (%#lx)\n", 529 545 *(uint32_t *)&g_awIdentify[117], *(uint32_t *)&g_awIdentify[117]); … … 531 547 printf("[%u]=%#06x - todo\n", i, g_awIdentify[i]); 532 548 for (i = 121; i <= 126; i++) 533 printf("[%u]=%#06x - reserved\n", i, g_awIdentify[i]);549 printf("[%u]=%#06x (reserved)\n", i, g_awIdentify[i]); 534 550 printf("[127]=%#06x - obsolete\n", g_awIdentify[127]); 535 551 printf("[128]=%#06x - security status - todo\n", g_awIdentify[128]); … … 538 554 printf("[160]=%#06x - CFA power mode - todo\n", g_awIdentify[160]); 539 555 for (i = 161; i <= 167; i++) 540 printf("[%u]=%#06x - reserved for CompactFlash guys\n", i, g_awIdentify[i]);541 printf("[168]=%#06x - Device nominal form factor - todo\n", g_awIdentify[16 0]);556 printf("[%u]=%#06x (reserved for the CompactFlash guys)\n", i, g_awIdentify[i]); 557 printf("[168]=%#06x - Device nominal form factor - todo\n", g_awIdentify[168]); 542 558 for (i = 169; i <= 175; i++) 543 printf("[%u]=%#06x - reserved\n", i, g_awIdentify[i]);544 printf("[176:205] - current media string: '%.60s'\n", i, &g_awIdentify[176]);559 printf("[%u]=%#06x (reserved)\n", i, g_awIdentify[i]); 560 AtaPrintIdString("[176:205] - current media string: ", &g_awIdentify[176], 30, "\n"); 545 561 printf("[206]=%#06x - SCT command transport - todo\n", g_awIdentify[206]); 546 printf("[207]=%#06x - reserved for CE-ATA - todo\n", g_awIdentify[207]);547 printf("[208]=%#06x - reserved for CE-ATA - todo\n", g_awIdentify[208]);548 printf("[209]=%#06x - logical block alignment - todo\n", g_awIdentify[20 6]);562 printf("[207]=%#06x (reserved for CE-ATA)\n", g_awIdentify[207]); 563 printf("[208]=%#06x (reserved for CE-ATA)\n", g_awIdentify[208]); 564 printf("[209]=%#06x - logical block alignment - todo\n", g_awIdentify[209]); 549 565 printf("[210:211] - Write-Read-Verify sector count mode 3: %lu (%#lx)\n", 550 566 *(uint32_t *)&g_awIdentify[210], *(uint32_t *)&g_awIdentify[210]); … … 555 571 *(uint32_t *)&g_awIdentify[215], *(uint32_t *)&g_awIdentify[215]); 556 572 printf("[217]=%#06x - Nominal media rotation rate: %u\n", g_awIdentify[217], g_awIdentify[217]); 557 printf("[218]=%#06x - reserved\n", g_awIdentify[218]);573 printf("[218]=%#06x (reserved)\n", g_awIdentify[218]); 558 574 printf("[219]=%#06x - NV cache options - todo\n", g_awIdentify[219]); 559 575 printf("[220]=%#06x - Current write-read-verify mode - todo\n", g_awIdentify[220]); 560 printf("[221]=%#06x - reserved\n", g_awIdentify[221]);576 printf("[221]=%#06x (reserved)\n", g_awIdentify[221]); 561 577 printf("[222]=%#06x - Transport major version number - todo\n", g_awIdentify[222]); 562 578 printf("[223]=%#06x - Transport minor version number: %u\n", g_awIdentify[223], g_awIdentify[223]); 563 579 for (i = 224; i <= 233; i++) 564 printf("[%u]=%#06x - reserved for CE-ATA\n", i, g_awIdentify[i]);580 printf("[%u]=%#06x (reserved for CE-ATA)\n", i, g_awIdentify[i]); 565 581 printf("[234]=%#06x - Min 512 bytes blocks per download microcode mode 3: %u\n", g_awIdentify[234], g_awIdentify[234]); 566 582 printf("[235]=%#06x - Max 512 bytes blocks per download microcode mode 3: %u\n", g_awIdentify[235], g_awIdentify[235]); 567 583 for (i = 236; i <= 254; i++) 568 printf("[%u]=%#06x - reserved\n", i, g_awIdentify[i]);584 printf("[%u]=%#06x (reserved)\n", i, g_awIdentify[i]); 569 585 570 586 printf("[255]=%#06x - Integrity word: ", g_awIdentify[255]);
Note:
See TracChangeset
for help on using the changeset viewer.