[75] | 1 | /* $Id: ataid.c 75 2015-12-27 19:47:37Z bird $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * Verbose display of the device identify reply.
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
| 7 | * Copyright (c) 2015 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
---|
| 8 | *
|
---|
| 9 | * This program is free software; you can redistribute it and/or modify
|
---|
| 10 | * it under the terms of the GNU General Public License as published by
|
---|
| 11 | * the Free Software Foundation; either version 3 of the License, or
|
---|
| 12 | * (at your option) any later version.
|
---|
| 13 | *
|
---|
| 14 | * This program is distributed in the hope that it will be useful,
|
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 17 | * GNU General Public License for more details.
|
---|
| 18 | *
|
---|
| 19 | * You should have received a copy of the GNU General Public License
|
---|
| 20 | * along with This program. If not, see <http://www.gnu.org/licenses/>
|
---|
| 21 | *
|
---|
| 22 | */
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | #include <stdio.h>
|
---|
| 26 | #include <stdlib.h>
|
---|
| 27 | #include <string.h>
|
---|
| 28 | #include <stdint.h>
|
---|
| 29 | #include <io.h>
|
---|
| 30 | #include <conio.h>
|
---|
| 31 | #include <time.h>
|
---|
| 32 |
|
---|
| 33 | #include "atalib.h"
|
---|
| 34 |
|
---|
| 35 |
|
---|
| 36 | uint8_t AtaCalcIdChecksum(void const *pv512Bytes)
|
---|
| 37 | {
|
---|
| 38 | uint8_t uCksum = 0;
|
---|
| 39 | uint8_t const *pb = (uint8_t const *)pv512Bytes;
|
---|
| 40 | size_t cbLeft = 511;
|
---|
| 41 | while (cbLeft-- > 0)
|
---|
| 42 | uCksum += *pb++;
|
---|
| 43 | return 0U - uCksum;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 |
|
---|
| 47 | int main(int argc, char **argv)
|
---|
| 48 | {
|
---|
| 49 | int rc;
|
---|
| 50 | unsigned i;
|
---|
| 51 | uint8_t bCksum;
|
---|
| 52 |
|
---|
| 53 | rc = AtaInitFromArgv(1, argc, argv);
|
---|
| 54 | if (rc != 0)
|
---|
| 55 | return 2;
|
---|
| 56 |
|
---|
| 57 | /*
|
---|
| 58 | * Format the identify device response already stored in g_awIdentify.
|
---|
| 59 | */
|
---|
| 60 | /* 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)
|
---|
| 90 | fputs("not implemented", stdout);
|
---|
| 91 | else if ((g_awIdentify[47] & 0xff) == 0)
|
---|
| 92 | printf("max %d sectors", g_awIdentify[47] & 0xff);
|
---|
| 93 | if ((g_awIdentify[47] >> 8) == 0x80)
|
---|
| 94 | fputs(", ATA-4 top value", stdout);
|
---|
| 95 | else
|
---|
| 96 | fputs(", vendor specific top value", stdout);
|
---|
| 97 | putchar('\n');
|
---|
| 98 |
|
---|
| 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));
|
---|
| 102 | else
|
---|
| 103 | fputs("not present\n", stdout);
|
---|
| 104 |
|
---|
| 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));
|
---|
| 135 | putchar('\n');
|
---|
| 136 | }
|
---|
| 137 | else
|
---|
| 138 | fputs("not present\n", stdout);
|
---|
| 139 |
|
---|
| 140 | printf("[ 51]=%#06x - obsolete PIO data transfer cycle timing mode %d", g_awIdentify[51], g_awIdentify[51] >> 8);
|
---|
| 141 | if (g_awIdentify[51] & UINT16_C(0x00ff))
|
---|
| 142 | printf(", vendor specific %#x\n", g_awIdentify[51] & UINT16_C(0x00ff));
|
---|
| 143 | else
|
---|
| 144 | putchar('\n');
|
---|
| 145 |
|
---|
| 146 | printf("[ 52]=%#06x - obsolete DMA data transfer cycle timing mode %d", g_awIdentify[52], g_awIdentify[52] >> 8);
|
---|
| 147 | if (g_awIdentify[52] & UINT16_C(0x00ff))
|
---|
| 148 | printf(", vendor specific %#x\n", g_awIdentify[52] & UINT16_C(0x00ff));
|
---|
| 149 | else
|
---|
| 150 | putchar('\n');
|
---|
| 151 |
|
---|
| 152 | printf("[ 53]=%#06x - ", g_awIdentify[53]);
|
---|
| 153 | if (g_awIdentify[53] & 1)
|
---|
| 154 | fputs(" words54-58-obsolete", stdout);
|
---|
| 155 | if (g_awIdentify[53] & 2)
|
---|
| 156 | fputs(" words64-70", stdout);
|
---|
| 157 | if (g_awIdentify[53] & 4)
|
---|
| 158 | fputs(" word88", stdout);
|
---|
| 159 | if (g_awIdentify[53] & UINT16_C(0x00f8))
|
---|
| 160 | printf(" rsvd=%#x", g_awIdentify[53] & UINT16_C(0x00f8));
|
---|
| 161 | printf(" free-fall-sensitivity=%#x\n", g_awIdentify[53] >> 8);
|
---|
| 162 |
|
---|
| 163 | printf("[ 54]=%#06x - obsolete current logical cylinders %d", g_awIdentify[54]);
|
---|
| 164 | if (g_awIdentify[54] > 16383)
|
---|
| 165 | fputs(" (high!)", stdout);
|
---|
| 166 | putchar('\n');
|
---|
| 167 |
|
---|
| 168 | printf("[ 55]=%#06x - obsolete current logical heads %d", g_awIdentify[55]);
|
---|
| 169 | if (g_awIdentify[55] > 16)
|
---|
| 170 | fputs(" (high!)", stdout);
|
---|
| 171 | putchar('\n');
|
---|
| 172 |
|
---|
| 173 | printf("[ 56]=%#06x - obsolete current logical sectors per track %d", g_awIdentify[56]);
|
---|
| 174 | if (g_awIdentify[56] > 63)
|
---|
| 175 | fputs(" (high!)", stdout);
|
---|
| 176 | putchar('\n');
|
---|
| 177 |
|
---|
| 178 | printf("[ 57:58] - obsolete current capacity in sectors %lu (%#lx)\n",
|
---|
| 179 | *(uint32_t *)&g_awIdentify[57], *(uint32_t *)&g_awIdentify[57]);
|
---|
| 180 |
|
---|
| 181 | printf("[ 59]=%#06x - sectors per DRQ READ/WRITE MULTIPLE ", g_awIdentify[59]);
|
---|
| 182 | if (g_awIdentify[59] & UINT16_C(0x0100))
|
---|
| 183 | printf("%d", g_awIdentify[59] & UINT16_C(0xff));
|
---|
| 184 | else
|
---|
| 185 | fputs(" not specified", stdout);
|
---|
| 186 | if (g_awIdentify[59] & UINT16_C(0xfe00))
|
---|
| 187 | printf(" rsvd=%#x", g_awIdentify[59] & UINT16_C(0xfe00));
|
---|
| 188 | putchar('\n');
|
---|
| 189 |
|
---|
| 190 | printf("[ 60:61] - LBA28 user addressable sectors %lu (%#lx)\n",
|
---|
| 191 | *(uint32_t *)&g_awIdentify[60], *(uint32_t *)&g_awIdentify[60]);
|
---|
| 192 |
|
---|
| 193 | printf("[ 62]=%#06x - obsolete single word DMA:", g_awIdentify[62]);
|
---|
| 194 | for (i = 0; i < 7; i++)
|
---|
| 195 | if (g_awIdentify[62] & (UINT16_C(0x0001) << i))
|
---|
| 196 | {
|
---|
| 197 | if (g_awIdentify[62] & (UINT16_C(0x0100) << i))
|
---|
| 198 | printf(" swdma%d[active]", i);
|
---|
| 199 | else
|
---|
| 200 | printf(" swdma%d", i);
|
---|
| 201 | }
|
---|
| 202 | else if (g_awIdentify[62] & (UINT16_C(0x0100) << i))
|
---|
| 203 | printf(" swdma%d-unsupported-but-active!", i);
|
---|
| 204 | putchar('\n');
|
---|
| 205 |
|
---|
| 206 | printf("[ 63]=%#06x - multiword DMA: ", g_awIdentify[63]);
|
---|
| 207 | for (i = 0; i < 7; i++)
|
---|
| 208 | if (g_awIdentify[63] & (UINT16_C(0x0001) << i))
|
---|
| 209 | {
|
---|
| 210 | if (g_awIdentify[63] & (UINT16_C(0x0100) << i))
|
---|
| 211 | printf(" mwdma%d[active]", i);
|
---|
| 212 | else
|
---|
| 213 | printf(" mwdma%d", i);
|
---|
| 214 | }
|
---|
| 215 | else if (g_awIdentify[63] & (UINT16_C(0x0100) << i))
|
---|
| 216 | printf(" mwdma%d-unsupported-but-active!", i);
|
---|
| 217 | putchar('\n');
|
---|
| 218 |
|
---|
| 219 | printf("[ 64]=%#06x - Advanced PIO modes: ", g_awIdentify[64]);
|
---|
| 220 | for (i = 0; i < 7; i++)
|
---|
| 221 | if (g_awIdentify[64] & (UINT16_C(0x0001) << i))
|
---|
| 222 | printf(" pio%d", i+3);
|
---|
| 223 | if (g_awIdentify[64] & UINT16_C(0xff00))
|
---|
| 224 | printf(" rsvd8-15=%#x", g_awIdentify[64] & UINT16_C(0xff00));
|
---|
| 225 | putchar('\n');
|
---|
| 226 |
|
---|
| 227 | printf("[ 65]=%#06x - minimum multiword DMA xfer cycle time per word %d ns\n", g_awIdentify[65], g_awIdentify[65]);
|
---|
| 228 | printf("[ 66]=%#06x - recommended multiword DMA xfer cycle time per word %d ns\n", g_awIdentify[66], g_awIdentify[66]);
|
---|
| 229 | printf("[ 67]=%#06x - minimum PIO cycle time without IORDY %d ns\n", g_awIdentify[67], g_awIdentify[67]);
|
---|
| 230 | 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]);
|
---|
| 237 |
|
---|
| 238 | printf("[ 75]=%#06x - queue depth %d", g_awIdentify[75], (g_awIdentify[75] & 0x1f) + 1);
|
---|
| 239 | if (g_awIdentify[75] & UINT16_C(0xffe0))
|
---|
| 240 | printf(", rsvd5-15=%#x", g_awIdentify[75] & UINT16_C(0xffe0));
|
---|
| 241 | putchar('\n');
|
---|
| 242 |
|
---|
| 243 | printf("[ 76]=%#06x - SATA capabilities: ", g_awIdentify[76]);
|
---|
| 244 | if (!(g_awIdentify[76] & 1))
|
---|
| 245 | {
|
---|
| 246 | if (g_awIdentify[76] & UINT16_C(0x0002))
|
---|
| 247 | fputs(" gen1-1.5Gbps", stdout);
|
---|
| 248 | if (g_awIdentify[76] & UINT16_C(0x0004))
|
---|
| 249 | fputs(" gen2-3.0Gbps", stdout);
|
---|
| 250 | if (g_awIdentify[76] & UINT16_C(0x00f8))
|
---|
| 251 | printf(" rsvd3-7=%#x", g_awIdentify[76] & UINT16_C(0x00f8));
|
---|
| 252 | if (g_awIdentify[76] & UINT16_C(0x0100))
|
---|
| 253 | fputs(" ncq", stdout);
|
---|
| 254 | if (g_awIdentify[76] & UINT16_C(0x0200))
|
---|
| 255 | fputs(" host-power-management", stdout);
|
---|
| 256 | if (g_awIdentify[76] & UINT16_C(0x0400))
|
---|
| 257 | fputs(" phy-event-counters", stdout);
|
---|
| 258 | if (g_awIdentify[76] & UINT16_C(0xf800))
|
---|
| 259 | printf(" rsvd11-16=%#x", g_awIdentify[76] & UINT16_C(0xf800));
|
---|
| 260 | putchar('\n');
|
---|
| 261 | }
|
---|
| 262 | else
|
---|
| 263 | fputs(" probably not SATA\n", stdout);
|
---|
| 264 |
|
---|
| 265 | printf("[ 77]=%#06x - reserved for SATA\n", g_awIdentify[77]);
|
---|
| 266 |
|
---|
| 267 | printf("[ 78]=%#06x - SATA features supported: ", g_awIdentify[78]);
|
---|
| 268 | if (!(g_awIdentify[78] & 1))
|
---|
| 269 | {
|
---|
| 270 | if (g_awIdentify[78] & UINT16_C(0x0002))
|
---|
| 271 | fputs(" non-zero-buffer-offsets", stdout);
|
---|
| 272 | if (g_awIdentify[78] & UINT16_C(0x0004))
|
---|
| 273 | fputs(" DMA-setup-auto-activation", stdout);
|
---|
| 274 | if (g_awIdentify[78] & UINT16_C(0x0008))
|
---|
| 275 | fputs(" device-power-management", stdout);
|
---|
| 276 | if (g_awIdentify[78] & UINT16_C(0x0010))
|
---|
| 277 | fputs(" in-order-data-delivery", stdout);
|
---|
| 278 | if (g_awIdentify[78] & UINT16_C(0x0020))
|
---|
| 279 | fputs(" rsvd5", stdout);
|
---|
| 280 | if (g_awIdentify[78] & UINT16_C(0x0040))
|
---|
| 281 | fputs(" software-settings-preservation", stdout);
|
---|
| 282 | if (g_awIdentify[78] & UINT16_C(0xff80))
|
---|
| 283 | printf(" rsvd7-15=%#x", g_awIdentify[78] & UINT16_C(0xff80));
|
---|
| 284 | putchar('\n');
|
---|
| 285 | }
|
---|
| 286 | else
|
---|
| 287 | fputs(" probably not SATA\n", stdout);
|
---|
| 288 |
|
---|
| 289 | printf("[ 79]=%#06x - SATA features enabled: ", g_awIdentify[79]);
|
---|
| 290 | if (!(g_awIdentify[79] & 1))
|
---|
| 291 | {
|
---|
| 292 | if (g_awIdentify[79] & UINT16_C(0x0002))
|
---|
| 293 | fputs(" non-zero-buffer-offsets", stdout);
|
---|
| 294 | if (g_awIdentify[79] & UINT16_C(0x0004))
|
---|
| 295 | fputs(" DMA-setup-auto-activation", stdout);
|
---|
| 296 | if (g_awIdentify[79] & UINT16_C(0x0008))
|
---|
| 297 | fputs(" device-power-management", stdout);
|
---|
| 298 | if (g_awIdentify[79] & UINT16_C(0x0010))
|
---|
| 299 | fputs(" in-order-data-delivery", stdout);
|
---|
| 300 | if (g_awIdentify[79] & UINT16_C(0x0020))
|
---|
| 301 | fputs(" rsvd5", stdout);
|
---|
| 302 | if (g_awIdentify[79] & UINT16_C(0x0040))
|
---|
| 303 | fputs(" software-settings-preservation", stdout);
|
---|
| 304 | if (g_awIdentify[79] & UINT16_C(0xff80))
|
---|
| 305 | printf(" rsvd7-15=%#x", g_awIdentify[79] & UINT16_C(0xff80));
|
---|
| 306 | putchar('\n');
|
---|
| 307 | }
|
---|
| 308 | else
|
---|
| 309 | fputs(" probably not SATA\n", stdout);
|
---|
| 310 |
|
---|
| 311 | printf("[ 80]=%#06x - Major version number:", g_awIdentify[80]);
|
---|
| 312 | if (g_awIdentify[80] != 0 && g_awIdentify[80] != UINT16_MAX)
|
---|
| 313 | {
|
---|
| 314 | for (i = 0; i < 15; i++)
|
---|
| 315 | if (g_awIdentify[80] & (UINT16_C(0x0001) << i))
|
---|
| 316 | printf(" ata%u", i);
|
---|
| 317 | }
|
---|
| 318 | else
|
---|
| 319 | fputs(" not specified\n", stdout);
|
---|
| 320 |
|
---|
| 321 | printf("[ 81]=%#06x - Minor version number: %d", g_awIdentify[81], g_awIdentify[81]);
|
---|
| 322 |
|
---|
| 323 | 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');
|
---|
| 341 |
|
---|
| 342 | printf("[ 83]=%#06x - Supports: ", g_awIdentify[83]);
|
---|
| 343 | if ((g_awIdentify[83] & UINT16_C(0xc000)) == UINT16_C(0x4000))
|
---|
| 344 | {
|
---|
| 345 |
|
---|
| 346 | if (g_awIdentify[83] & UINT16_C(0x0001)) fputs(" download-microcode", stdout);
|
---|
| 347 | if (g_awIdentify[83] & UINT16_C(0x0002)) fputs(" tcq", stdout);
|
---|
| 348 | if (g_awIdentify[83] & UINT16_C(0x0004)) fputs(" cfa", stdout);
|
---|
| 349 | if (g_awIdentify[83] & UINT16_C(0x0008)) fputs(" apm", stdout);
|
---|
| 350 | if (g_awIdentify[83] & UINT16_C(0x0010)) fputs(" obsolete4", stdout);
|
---|
| 351 | if (g_awIdentify[83] & UINT16_C(0x0020)) fputs(" puis", stdout);
|
---|
| 352 | if (g_awIdentify[83] & UINT16_C(0x0040)) fputs(" set-features-spin-up", stdout);
|
---|
| 353 | if (g_awIdentify[83] & UINT16_C(0x0080)) fputs(" reserved7", stdout);
|
---|
| 354 | if (g_awIdentify[83] & UINT16_C(0x0100)) fputs(" set-max-security", stdout);
|
---|
| 355 | if (g_awIdentify[83] & UINT16_C(0x0200)) fputs(" aam", stdout);
|
---|
| 356 | if (g_awIdentify[83] & UINT16_C(0x0400)) fputs(" lba48", stdout);
|
---|
| 357 | if (g_awIdentify[83] & UINT16_C(0x0800)) fputs(" dco", stdout);
|
---|
| 358 | if (g_awIdentify[83] & UINT16_C(0x1000)) fputs(" flush-cache", stdout);
|
---|
| 359 | if (g_awIdentify[83] & UINT16_C(0x2000)) fputs(" flush-cache-ext", stdout);
|
---|
| 360 | putchar('\n');
|
---|
| 361 | }
|
---|
| 362 | else
|
---|
| 363 | fputs(" not specified\n", stdout);
|
---|
| 364 |
|
---|
| 365 | printf("[ 84]=%#06x - Supports: ", g_awIdentify[84]);
|
---|
| 366 | if ((g_awIdentify[84] & UINT16_C(0xc000)) == UINT16_C(0x4000))
|
---|
| 367 | {
|
---|
| 368 | if (g_awIdentify[84] & UINT16_C(0x0001)) fputs(" smart-err-log", stdout);
|
---|
| 369 | if (g_awIdentify[84] & UINT16_C(0x0002)) fputs(" smart-self-test", stdout);
|
---|
| 370 | if (g_awIdentify[84] & UINT16_C(0x0004)) fputs(" media-serial-no", stdout);
|
---|
| 371 | if (g_awIdentify[84] & UINT16_C(0x0008)) fputs(" media-card-passthru", stdout);
|
---|
| 372 | if (g_awIdentify[84] & UINT16_C(0x0010)) fputs(" streaming", stdout);
|
---|
| 373 | if (g_awIdentify[84] & UINT16_C(0x0020)) fputs(" gpl", stdout);
|
---|
| 374 | if (g_awIdentify[84] & UINT16_C(0x0040)) fputs(" write-dma-mult-fua-ext", stdout);
|
---|
| 375 | if (g_awIdentify[84] & UINT16_C(0x0080)) fputs(" write-dma-queued-fua-ext", stdout);
|
---|
| 376 | if (g_awIdentify[84] & UINT16_C(0x0100)) fputs(" 64-bit-world-wide-name", stdout);
|
---|
| 377 | if (g_awIdentify[84] & UINT16_C(0x0200)) fputs(" obsolete9", stdout);
|
---|
| 378 | if (g_awIdentify[84] & UINT16_C(0x0400)) fputs(" obsolete10", stdout);
|
---|
| 379 | if (g_awIdentify[84] & UINT16_C(0x0800)) fputs(" reserved11", stdout);
|
---|
| 380 | if (g_awIdentify[84] & UINT16_C(0x1000)) fputs(" reserved12", stdout);
|
---|
| 381 | if (g_awIdentify[84] & UINT16_C(0x2000)) fputs(" idle-immediate-unload", stdout);
|
---|
| 382 | putchar('\n');
|
---|
| 383 | }
|
---|
| 384 | else
|
---|
| 385 | fputs(" not specified\n", stdout);
|
---|
| 386 |
|
---|
| 387 | printf("[ 85]=%#06x - Enabled:", g_awIdentify[85]);
|
---|
| 388 | if (g_awIdentify[85] & UINT16_C(0x0001)) fputs(" smart", stdout);
|
---|
| 389 | if (g_awIdentify[85] & UINT16_C(0x0002)) fputs(" security", stdout);
|
---|
| 390 | if (g_awIdentify[85] & UINT16_C(0x0020)) fputs(" volatile-write-cache", stdout);
|
---|
| 391 | if (g_awIdentify[85] & UINT16_C(0x0040)) fputs(" look-ahead", stdout);
|
---|
| 392 | if (g_awIdentify[85] & UINT16_C(0x0080)) fputs(" release-intr", stdout);
|
---|
| 393 | if (g_awIdentify[85] & UINT16_C(0x0100)) fputs(" service-intr", stdout);
|
---|
| 394 | fputs(" Supported:", stdout);
|
---|
| 395 | if (g_awIdentify[85] & UINT16_C(0x0004)) fputs(" obsolete2", stdout);
|
---|
| 396 | if (g_awIdentify[85] & UINT16_C(0x0008)) fputs(" mand-power-management", stdout);
|
---|
| 397 | if (!(g_awIdentify[85] & UINT16_C(0x0010))) fputs(" no-packet", stdout);
|
---|
| 398 | if (!(g_awIdentify[85] & UINT16_C(0x0200))) fputs(" no-device-reset", stdout);
|
---|
| 399 | if (g_awIdentify[85] & UINT16_C(0x0400)) fputs(" hpa", stdout);
|
---|
| 400 | if (g_awIdentify[85] & UINT16_C(0x0800)) fputs(" obsolete11", stdout);
|
---|
| 401 | if (g_awIdentify[85] & UINT16_C(0x1000)) fputs(" write-buffer", stdout);
|
---|
| 402 | if (g_awIdentify[85] & UINT16_C(0x2000)) fputs(" read-buffer", stdout);
|
---|
| 403 | if (g_awIdentify[85] & UINT16_C(0x4000)) fputs(" nop", stdout);
|
---|
| 404 | if (g_awIdentify[85] & UINT16_C(0x8000)) fputs(" obsolete15", stdout);
|
---|
| 405 | putchar('\n');
|
---|
| 406 |
|
---|
| 407 | if ((g_awIdentify[83] & UINT16_C(0xc000)) == UINT16_C(0x4000)) /* yeah, 83. */
|
---|
| 408 | {
|
---|
| 409 | printf("[ 86]=%#06x - Enabled: ", g_awIdentify[86]);
|
---|
| 410 | if (g_awIdentify[86] & UINT16_C(0x0008)) fputs(" apm", stdout);
|
---|
| 411 | if (g_awIdentify[86] & UINT16_C(0x0020)) fputs(" puis", stdout);
|
---|
| 412 | if (g_awIdentify[86] & UINT16_C(0x0100)) fputs(" set-max-security", stdout);
|
---|
| 413 | if (g_awIdentify[86] & UINT16_C(0x0200)) fputs(" aam", stdout);
|
---|
| 414 | fputs(" Supported:", stdout);
|
---|
| 415 | if (g_awIdentify[86] & UINT16_C(0x0001)) fputs(" download-microcode", stdout);
|
---|
| 416 | if (g_awIdentify[86] & UINT16_C(0x0002)) fputs(" tcq", stdout);
|
---|
| 417 | if (g_awIdentify[86] & UINT16_C(0x0004)) fputs(" cfa", stdout);
|
---|
| 418 | if (g_awIdentify[86] & UINT16_C(0x0010)) fputs(" obsolete4", stdout);
|
---|
| 419 | if (g_awIdentify[86] & UINT16_C(0x0040)) fputs(" set-features-spin-up", stdout);
|
---|
| 420 | if (g_awIdentify[86] & UINT16_C(0x0080)) fputs(" reserved7", stdout);
|
---|
| 421 | if (g_awIdentify[86] & UINT16_C(0x0400)) fputs(" lba48", stdout);
|
---|
| 422 | if (g_awIdentify[86] & UINT16_C(0x0800)) fputs(" dco", stdout);
|
---|
| 423 | if (g_awIdentify[86] & UINT16_C(0x1000)) fputs(" flush-cache", stdout);
|
---|
| 424 | if (g_awIdentify[86] & UINT16_C(0x2000)) fputs(" flush-cache-ext", stdout);
|
---|
| 425 | if (g_awIdentify[86] & UINT16_C(0x4000)) fputs(" reserved14", stdout);
|
---|
| 426 | if (g_awIdentify[86] & UINT16_C(0x8000)) fputs(" words119-120", stdout);
|
---|
| 427 | putchar('\n');
|
---|
| 428 | }
|
---|
| 429 | else
|
---|
| 430 | printf("[ 86]=%#06x - Enabled & Supports: not specified\n", g_awIdentify[86]);
|
---|
| 431 |
|
---|
| 432 | printf("[ 87]=%#06x - Enabled: ", g_awIdentify[87]);
|
---|
| 433 | if ((g_awIdentify[87] & UINT16_C(0xc000)) == UINT16_C(0x4000))
|
---|
| 434 | {
|
---|
| 435 | if (g_awIdentify[87] & UINT16_C(0x0004)) fputs(" media-serial-no-valid", stdout);
|
---|
| 436 | fputs(" Supported:", stdout);
|
---|
| 437 | if (g_awIdentify[87] & UINT16_C(0x0001)) fputs(" smart-err-log", stdout);
|
---|
| 438 | if (g_awIdentify[87] & UINT16_C(0x0002)) fputs(" smart-self-test", stdout);
|
---|
| 439 | if (g_awIdentify[87] & UINT16_C(0x0008)) fputs(" media-card-passthru", stdout);
|
---|
| 440 | if (g_awIdentify[87] & UINT16_C(0x0010)) fputs(" obsolete4", stdout);
|
---|
| 441 | if (g_awIdentify[87] & UINT16_C(0x0020)) fputs(" gpl", stdout);
|
---|
| 442 | if (g_awIdentify[87] & UINT16_C(0x0040)) fputs(" write-dma-mult-fua-ext", stdout);
|
---|
| 443 | if (g_awIdentify[87] & UINT16_C(0x0080)) fputs(" write-dma-queued-fua-ext", stdout);
|
---|
| 444 | if (g_awIdentify[87] & UINT16_C(0x0100)) fputs(" 64-bit-world-wide-name", stdout);
|
---|
| 445 | if (g_awIdentify[87] & UINT16_C(0x0200)) fputs(" obsolete9", stdout);
|
---|
| 446 | if (g_awIdentify[87] & UINT16_C(0x0400)) fputs(" obsolete10", stdout);
|
---|
| 447 | if (g_awIdentify[87] & UINT16_C(0x0800)) fputs(" reserved11", stdout);
|
---|
| 448 | if (g_awIdentify[87] & UINT16_C(0x1000)) fputs(" reserved12", stdout);
|
---|
| 449 | if (g_awIdentify[87] & UINT16_C(0x2000)) fputs(" idle-immediate-unload", stdout);
|
---|
| 450 | putchar('\n');
|
---|
| 451 | }
|
---|
| 452 | else
|
---|
| 453 | fputs(" not specified\n", stdout);
|
---|
| 454 |
|
---|
| 455 | printf("[ 88]=%#06x - Ultra DMA support: ", g_awIdentify[88]);
|
---|
| 456 | for (i = 0; i < 8; i++)
|
---|
| 457 | if (g_awIdentify[88] & (UINT16_C(0x0001) << i))
|
---|
| 458 | printf(" <=udma%d", i);
|
---|
| 459 | fputs(" Selected: ", stdout);
|
---|
| 460 | for (i = 0; i < 8; i++)
|
---|
| 461 | if (g_awIdentify[88] & (UINT16_C(0x0100) << i))
|
---|
| 462 | printf(" udma%d", i);
|
---|
| 463 | putchar('\n');
|
---|
| 464 |
|
---|
| 465 | printf("[ 89]=%#06x - time for normal erase mode security erase unit: %d\n",
|
---|
| 466 | g_awIdentify[88], g_awIdentify[89] & UINT16_C(0x00ff));
|
---|
| 467 | printf("[ 90]=%#06x - time for enh. erase mode security erase unit: %d\n",
|
---|
| 468 | g_awIdentify[90], g_awIdentify[90] & UINT16_C(0x00ff));
|
---|
| 469 | printf("[ 91]=%#06x - current APM level value: %d\n", g_awIdentify[91], g_awIdentify[91]);
|
---|
| 470 | printf("[ 92]=%#06x - master password ID: %d\n", g_awIdentify[92], g_awIdentify[92]);
|
---|
| 471 |
|
---|
| 472 | printf("[ 93]=%#06x - hardware reset result:", g_awIdentify[92], g_awIdentify[92]);
|
---|
| 473 | if ((g_awIdentify[93] & UINT16_C(0xc000)) == UINT16_C(0x4000))
|
---|
| 474 | {
|
---|
| 475 | static const char * const s_apszDevNum[4] = { " rsvd0", " jumper", " csel", " other" };
|
---|
| 476 | if (g_awIdentify[93] & UINT16_C(0x00ff))
|
---|
| 477 | {
|
---|
| 478 | fputs(" dev0: ", stdout);
|
---|
| 479 | fputs(s_apszDevNum[(g_awIdentify[93] >> 1) & 3], stdout);
|
---|
| 480 | if (!(g_awIdentify[93] & UINT16_C(0x0001))) fputs(" bit0-clear!", stdout);
|
---|
| 481 | fputs(g_awIdentify[93] & UINT16_C(0x0008) ? "diag-passed" : "diag-failed!", stdout);
|
---|
| 482 | fputs(g_awIdentify[93] & UINT16_C(0x0010) ? "PDIGA-" : "no-PDIAG-", stdout);
|
---|
| 483 | fputs(g_awIdentify[93] & UINT16_C(0x0020) ? "DASP-" : "no-DASP-", stdout);
|
---|
| 484 | fputs(g_awIdentify[93] & UINT16_C(0x0040) ? "responds-when-dev1-selected" : "dev1-can-be-selected", stdout);
|
---|
| 485 | if (g_awIdentify[93] & UINT16_C(0x0080)) fputs(" rsvd7!", stdout);
|
---|
| 486 | }
|
---|
| 487 | if (g_awIdentify[93] & UINT16_C(0x0f00))
|
---|
| 488 | {
|
---|
| 489 | fputs(" dev1: ", stdout);
|
---|
| 490 | fputs(s_apszDevNum[(g_awIdentify[93] >> 9) & 3], stdout);
|
---|
| 491 | fputs(g_awIdentify[93] & UINT16_C(0x0800) ? "PDIGA-" : "no-PDIAG-", stdout);
|
---|
| 492 | if (!(g_awIdentify[93] & UINT16_C(0x0100))) fputs(" bit8-clear!", stdout);
|
---|
| 493 | if (g_awIdentify[93] & UINT16_C(0x1000)) fputs(" rsvd12!", stdout);
|
---|
| 494 | }
|
---|
| 495 | fputs(g_awIdentify[93] & UINT16_C(0x2000) ? "CBLID-below-ViL" : "CBLID-above-ViHB", stdout);
|
---|
| 496 | putchar('\n');
|
---|
| 497 | }
|
---|
| 498 | else
|
---|
| 499 | fputs(" not specified\n", stdout);
|
---|
| 500 |
|
---|
| 501 | printf("[ 94]=%#06x - recommended AAM value: %#x current: %#x\n",
|
---|
| 502 | g_awIdentify[94], g_awIdentify[94] >> 8, g_awIdentify[94] & UINT16_C(0x00ff));
|
---|
| 503 | printf("[ 95]=%#06x - stream minimum request size: %d\n", g_awIdentify[95], g_awIdentify[95]);
|
---|
| 504 | printf("[ 96]=%#06x - streaming transfer time, DMA: %d\n", g_awIdentify[96], g_awIdentify[96]);
|
---|
| 505 | printf("[ 97]=%#06x - streaming access latency, DMA+PIO: %d\n", g_awIdentify[97], g_awIdentify[97]);
|
---|
| 506 | printf("[ 98:99] - streaming performance granularity: %ld (%#lx)\n",
|
---|
| 507 | *(uint32_t *)&g_awIdentify[98], *(uint32_t *)&g_awIdentify[98]);
|
---|
| 508 | printf("[100:103] - LBA48 user addressable sectors: %lld (%#llx)\n",
|
---|
| 509 | *(uint64_t *)&g_awIdentify[100], *(uint64_t *)&g_awIdentify[100]);
|
---|
| 510 | printf("[104]=%#06x - streaming transfer time, PIO: %d\n", g_awIdentify[104], g_awIdentify[104]);
|
---|
| 511 | printf("[105]=%#06x - reserved\n", g_awIdentify[105]);
|
---|
| 512 | if ((g_awIdentify[106] & UINT16_C(0xc000)) == UINT16_C(0x4000))
|
---|
| 513 | {
|
---|
| 514 | printf("[106]=%#06x - Physical/logical sector size: %u logical per physical",
|
---|
| 515 | g_awIdentify[106], 1U << (g_awIdentify[106] & 0xfU));
|
---|
| 516 | if (g_awIdentify[106] & UINT16_C(0x1000)) fputs(", more-than-512-byte-logical", stdout);
|
---|
| 517 | if (g_awIdentify[106] & UINT16_C(0x2000)) fputs(", multiple-logical-per-physical", stdout);
|
---|
| 518 | if (g_awIdentify[106] & UINT16_C(0x0ff0)) printf("rsvd4-11=%#x", g_awIdentify[106] & UINT16_C(0x0ff0));
|
---|
| 519 | putchar('\n');
|
---|
| 520 | }
|
---|
| 521 | else
|
---|
| 522 | printf("[106]=%#06x - Physical/logical sector size: not specified", g_awIdentify[106]);
|
---|
| 523 |
|
---|
| 524 | 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[107]);
|
---|
| 526 | for (i = 112; i <= 116; i++)
|
---|
| 527 | printf("[%u]=%#06x - reserved\n", i, g_awIdentify[i]);
|
---|
| 528 | printf("[117:118] - Logical sector size: %lu bytes (%#lx)\n",
|
---|
| 529 | *(uint32_t *)&g_awIdentify[117], *(uint32_t *)&g_awIdentify[117]);
|
---|
| 530 | for (i = 119; i <= 120; i++)
|
---|
| 531 | printf("[%u]=%#06x - todo\n", i, g_awIdentify[i]);
|
---|
| 532 | for (i = 121; i <= 126; i++)
|
---|
| 533 | printf("[%u]=%#06x - reserved\n", i, g_awIdentify[i]);
|
---|
| 534 | printf("[127]=%#06x - obsolete\n", g_awIdentify[127]);
|
---|
| 535 | printf("[128]=%#06x - security status - todo\n", g_awIdentify[128]);
|
---|
| 536 | for (i = 129; i <= 159; i++)
|
---|
| 537 | printf("[%u]=%#06x - vendor specific\n", i, g_awIdentify[i]);
|
---|
| 538 | printf("[160]=%#06x - CFA power mode - todo\n", g_awIdentify[160]);
|
---|
| 539 | 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[160]);
|
---|
| 542 | 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]);
|
---|
| 545 | 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[206]);
|
---|
| 549 | printf("[210:211] - Write-Read-Verify sector count mode 3: %lu (%#lx)\n",
|
---|
| 550 | *(uint32_t *)&g_awIdentify[210], *(uint32_t *)&g_awIdentify[210]);
|
---|
| 551 | printf("[212:213] - Write-Read-Verify sector count mode 2: %lu (%#lx)\n",
|
---|
| 552 | *(uint32_t *)&g_awIdentify[212], *(uint32_t *)&g_awIdentify[212]);
|
---|
| 553 | printf("[214]=%#06x - NV cache capabilities - todo\n", g_awIdentify[214]);
|
---|
| 554 | printf("[215:216] - NV cache size: %lu logical blocks (%#lx)\n",
|
---|
| 555 | *(uint32_t *)&g_awIdentify[215], *(uint32_t *)&g_awIdentify[215]);
|
---|
| 556 | printf("[217]=%#06x - Nominal media rotation rate: %u\n", g_awIdentify[217], g_awIdentify[217]);
|
---|
| 557 | printf("[218]=%#06x - reserved\n", g_awIdentify[218]);
|
---|
| 558 | printf("[219]=%#06x - NV cache options - todo\n", g_awIdentify[219]);
|
---|
| 559 | printf("[220]=%#06x - Current write-read-verify mode - todo\n", g_awIdentify[220]);
|
---|
| 560 | printf("[221]=%#06x - reserved\n", g_awIdentify[221]);
|
---|
| 561 | printf("[222]=%#06x - Transport major version number - todo\n", g_awIdentify[222]);
|
---|
| 562 | printf("[223]=%#06x - Transport minor version number: %u\n", g_awIdentify[223], g_awIdentify[223]);
|
---|
| 563 | for (i = 224; i <= 233; i++)
|
---|
| 564 | printf("[%u]=%#06x - reserved for CE-ATA\n", i, g_awIdentify[i]);
|
---|
| 565 | printf("[234]=%#06x - Min 512 bytes blocks per download microcode mode 3: %u\n", g_awIdentify[234], g_awIdentify[234]);
|
---|
| 566 | printf("[235]=%#06x - Max 512 bytes blocks per download microcode mode 3: %u\n", g_awIdentify[235], g_awIdentify[235]);
|
---|
| 567 | for (i = 236; i <= 254; i++)
|
---|
| 568 | printf("[%u]=%#06x - reserved\n", i, g_awIdentify[i]);
|
---|
| 569 |
|
---|
| 570 | printf("[255]=%#06x - Integrity word: ", g_awIdentify[255]);
|
---|
| 571 | bCksum = AtaCalcIdChecksum(g_awIdentify);
|
---|
| 572 | if ((g_awIdentify[255] & UINT16_C(0xff)) == UINT16_C(0x00A5) /* ATA-8 7.16.7.88 */)
|
---|
| 573 | {
|
---|
| 574 | if ((g_awIdentify[255] >> 8) == bCksum)
|
---|
| 575 | printf("cksum=%#x (correct)\n", g_awIdentify[255] >> 8);
|
---|
| 576 | else
|
---|
| 577 | printf("cksum=%#x bad!, correct=%#x\n", g_awIdentify[255] >> 8, bCksum);
|
---|
| 578 | }
|
---|
| 579 | else
|
---|
| 580 | printf(" no checksum (should be %#x)\n", bCksum);
|
---|
| 581 |
|
---|
| 582 | return 0;
|
---|
| 583 | }
|
---|
| 584 |
|
---|