1 /*-
2 * Copyright (c) 1998 - 2004 Søren Schmidt <sos@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <sys/cdefs.h>
30 __FBSDID("$FreeBSD$");
31
32 #include "opt_ata.h"
33 #include <sys/param.h>
34 #include <sys/systm.h>
35 #include <sys/ata.h>
36 #include <sys/kernel.h>
37 #include <sys/bio.h>
38 #include <sys/bus.h>
39 #include <sys/conf.h>
40 #include <sys/sema.h>
41 #include <sys/taskqueue.h>
42 #include <vm/uma.h>
43 #include <machine/bus.h>
44 #include <sys/rman.h>
45 #include <dev/ata/ata-all.h>
46
47 /* prototypes */
48 static void ata_completed(void *, int);
49 static void ata_timeout(struct ata_request *);
50 static char *ata_skey2str(u_int8_t);
51
52 void
53 ata_queue_request(struct ata_request *request)
54 {
55 struct ata_channel *ch = request->device->channel;
56
57 /* mark request as virgin */
58 request->result = request->status = request->error = 0;
59 callout_init(&request->callout, 1);
60
61 if (!request->callback && !(request->flags & ATA_R_REQUEUE))
62 sema_init(&request->done, 0, "ATA request done");
63
64 /* in IMMEDIATE_MODE we dont queue but call HW directly */
65 /* used only during reinit for getparm and config */
66 if ((ch->flags & ATA_IMMEDIATE_MODE) &&
67 (request->flags & (ATA_R_CONTROL | ATA_R_IMMEDIATE))) {
68
69 /* arm timeout */
70 if (!dumping)
71 callout_reset(&request->callout, request->timeout * hz,
72 (timeout_t*)ata_timeout, request);
73
74 /* kick HW into action */
75 ch->running = request;
76 if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
77 ch->running = NULL;
78 callout_drain(&request->callout);
79 if (!request->callback)
80 sema_destroy(&request->done);
81 return;
82 }
83 }
84 else {
85 /* put request on the locked queue at the specified location */
86 mtx_lock(&ch->queue_mtx);
87 if (request->flags & ATA_R_IMMEDIATE)
88 TAILQ_INSERT_HEAD(&ch->ata_queue, request, chain);
89 else
90 TAILQ_INSERT_TAIL(&ch->ata_queue, request, chain);
91 mtx_unlock(&ch->queue_mtx);
92 ATA_DEBUG_RQ(request, "queued");
93 ata_start(ch);
94 }
95
96 /* if this is a requeued request callback/sleep has been setup */
97 if (request->flags & ATA_R_REQUEUE)
98 return;
99
100 /* if this is not a callback wait until request is completed */
101 if (!request->callback) {
102 ATA_DEBUG_RQ(request, "wait for completion");
103 sema_wait(&request->done);
104 sema_destroy(&request->done);
105 }
106 }
107
108 int
109 ata_controlcmd(struct ata_device *atadev, u_int8_t command, u_int16_t feature,
110 u_int64_t lba, u_int16_t count)
111 {
112 struct ata_request *request = ata_alloc_request();
113 int error = ENOMEM;
114
115 if (request) {
116 request->device = atadev;
117 request->u.ata.command = command;
118 request->u.ata.lba = lba;
119 request->u.ata.count = count;
120 request->u.ata.feature = feature;
121 request->flags = ATA_R_CONTROL;
122 request->timeout = 5;
123 request->retries = 0;
124 ata_queue_request(request);
125 error = request->result;
126 ata_free_request(request);
127 }
128 return error;
129 }
130
131 int
132 ata_atapicmd(struct ata_device *atadev, u_int8_t *ccb, caddr_t data,
133 int count, int flags, int timeout)
134 {
135 struct ata_request *request = ata_alloc_request();
136 int error = ENOMEM;
137
138 if (request) {
139 request->device = atadev;
140 if ((atadev->param->config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12)
141 bcopy(ccb, request->u.atapi.ccb, 12);
142 else
143 bcopy(ccb, request->u.atapi.ccb, 16);
144 request->data = data;
145 request->bytecount = count;
146 request->transfersize = min(request->bytecount, 65534);
147 request->flags = flags | ATA_R_ATAPI;
148 request->timeout = timeout;
149 ata_queue_request(request);
150 error = request->result;
151 ata_free_request(request);
152 }
153 return error;
154 }
155
156 void
157 ata_start(struct ata_channel *ch)
158 {
159 struct ata_request *request;
160
161 /* if in immediate mode, just skip start requests (stall queue) */
162 if (ch->flags & ATA_IMMEDIATE_MODE)
163 return;
164
165 /* if we dont have any work, ask the subdriver(s) */
166 mtx_lock(&ch->queue_mtx);
167 if (TAILQ_EMPTY(&ch->ata_queue)) {
168 mtx_unlock(&ch->queue_mtx);
169 if (ch->device[MASTER].start)
170 ch->device[MASTER].start(&ch->device[MASTER]);
171 if (ch->device[SLAVE].start)
172 ch->device[SLAVE].start(&ch->device[SLAVE]);
173 mtx_lock(&ch->queue_mtx);
174 }
175
176 /* if we have a request on the queue try to get it running */
177 if ((request = TAILQ_FIRST(&ch->ata_queue))) {
178
179 /* we need the locking function to get the lock for this channel */
180 if (ch->locking(ch, ATA_LF_LOCK) == ch->unit) {
181
182 /* check for the right state */
183 mtx_lock(&ch->state_mtx);
184 if (ch->state == ATA_IDLE) {
185 ATA_DEBUG_RQ(request, "starting");
186 TAILQ_REMOVE(&ch->ata_queue, request, chain);
187 ch->running = request;
188 ch->state = ATA_ACTIVE;
189 if (!dumping)
190 callout_reset(&request->callout, request->timeout * hz,
191 (timeout_t*)ata_timeout, request);
192 if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
193 ch->running = NULL;
194 ch->state = ATA_IDLE;
195 mtx_unlock(&ch->queue_mtx);
196 mtx_unlock(&ch->state_mtx);
197 ch->locking(ch, ATA_LF_UNLOCK);
198 ata_finish(request);
199 return;
200 }
201 }
202 mtx_unlock(&ch->state_mtx);
203 }
204 }
205 mtx_unlock(&ch->queue_mtx);
206 }
207
208 void
209 ata_finish(struct ata_request *request)
210 {
211 struct ata_channel *ch = request->device->channel;
212
213 /* schedule it for completition */
214 if (ch->flags & ATA_IMMEDIATE_MODE) {
215 ATA_DEBUG_RQ(request, "finish directly");
216 ata_completed(request, 0);
217 }
218 else {
219 /* reset timeout and put on the proper taskqueue for completion */
220 if (!dumping && !(request->flags & ATA_R_TIMEOUT))
221 callout_reset(&request->callout, request->timeout * hz,
222 (timeout_t*)ata_timeout, request);
223 if (request->bio && !(request->flags & ATA_R_TIMEOUT)) {
224 ATA_DEBUG_RQ(request, "finish bio_taskqueue");
225 bio_taskqueue(request->bio, (bio_task_t *)ata_completed, request);
226 }
227 else {
228 TASK_INIT(&request->task, 0, ata_completed, request);
229 ATA_DEBUG_RQ(request, "finish taskqueue_thread");
230 taskqueue_enqueue(taskqueue_thread, &request->task);
231 }
232 }
233 }
234
235 static void
236 ata_completed(void *context, int dummy)
237 {
238 struct ata_request *request = (struct ata_request *)context;
239 struct ata_channel *ch = request->device->channel;
240
241 ATA_DEBUG_RQ(request, "completed entered");
242
243 /* if we had a timeout, reinit channel and deal with the falldown */
244 if (request->flags & ATA_R_TIMEOUT) {
245 /*
246 * if reinit succeeds, retries still permit and device didn't
247 * get removed by the reinit, reinject request
248 */
249 if (!ata_reinit(ch) && request->retries-- > 0
250 && request->device->param){
251 request->flags &= ~(ATA_R_TIMEOUT | ATA_R_DEBUG);
252 request->flags |= (ATA_R_IMMEDIATE | ATA_R_REQUEUE);
253 request->donecount = 0;
254 ATA_DEBUG_RQ(request, "completed reinject");
255 ata_queue_request(request);
256 return;
257 }
258
259 /* nothing more to try so finish with error */
260 if (!(request->flags & ATA_R_QUIET))
261 ata_prtdev(request->device,
262 "FAILURE - %s timed out\n",
263 ata_cmd2str(request));
264 if (!request->result)
265 request->result = EIO;
266 }
267 else {
268 /* untimeout request now we have control back */
269 callout_drain(&request->callout);
270
271 /* if this is a soft ECC error warn about it */
272 if ((request->status & (ATA_S_CORR | ATA_S_ERROR)) == ATA_S_CORR) {
273 ata_prtdev(request->device,
274 "WARNING - %s soft error (ECC corrected)",
275 ata_cmd2str(request));
276 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
277 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
278 printf("\n");
279 }
280
281 /* if this is a UDMA CRC error, retry request */
282 if (request->flags & ATA_R_DMA && request->error & ATA_E_ICRC) {
283 if (request->retries-- > 0) {
284 ata_prtdev(request->device,
285 "WARNING - %s UDMA ICRC error (retrying request)",
286 ata_cmd2str(request));
287 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
288 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
289 printf("\n");
290 request->flags |= (ATA_R_IMMEDIATE | ATA_R_REQUEUE);
291 ata_queue_request(request);
292 return;
293 }
294 }
295 }
296
297 switch (request->flags & ATA_R_ATAPI) {
298
299 /* ATA errors */
300 default:
301 if (!request->result && request->status & ATA_S_ERROR) {
302 if (!(request->flags & ATA_R_QUIET)) {
303 ata_prtdev(request->device,
304 "FAILURE - %s status=%b error=%b",
305 ata_cmd2str(request),
306 request->status, "\2\10BUSY\7READY\6DMA_READY"
307 "\5DSC\4DRQ\3CORRECTABLE\2INDEX\1ERROR",
308 request->error, "\2\10ICRC\7UNCORRECTABLE"
309 "\6MEDIA_CHANGED\5NID_NOT_FOUND\4MEDIA_CHANGE_REQEST"
310 "\3ABORTED\2NO_MEDIA\1ILLEGAL_LENGTH");
311 if ((request->flags & ATA_R_DMA) &&
312 (request->dmastat & ATA_BMSTAT_ERROR))
313 printf(" dma=0x%02x", request->dmastat);
314 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
315 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
316 printf("\n");
317 }
318
319 /* SOS this could be more precise ? XXX */
320 request->result = EIO;
321 }
322 break;
323
324 /* ATAPI errors */
325 case ATA_R_ATAPI:
326 /* skip if result already set */
327 if (request->result)
328 break;
329
330 /* if we have a sensekey -> request sense from device */
331 if (request->error & ATA_SK_MASK &&
332 request->u.atapi.ccb[0] != ATAPI_REQUEST_SENSE) {
333 static u_int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0,
334 sizeof(struct atapi_sense),
335 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
336
337 request->u.atapi.sense_key = request->error;
338 request->u.atapi.sense_cmd = request->u.atapi.ccb[0];
339 bcopy(ccb, request->u.atapi.ccb, 16);
340 request->data = (caddr_t)&request->u.atapi.sense_data;
341 request->bytecount = sizeof(struct atapi_sense);
342 request->transfersize = sizeof(struct atapi_sense);
343 request->donecount = 0;
344 request->timeout = 5;
345 request->flags &= (ATA_R_ATAPI | ATA_R_QUIET);
346 request->flags |= (ATA_R_READ | ATA_R_IMMEDIATE | ATA_R_REQUEUE);
347 ATA_DEBUG_RQ(request, "autoissue request sense");
348 ata_queue_request(request);
349 return;
350 }
351
352 switch (request->u.atapi.sense_key & ATA_SK_MASK) {
353 case ATA_SK_RECOVERED_ERROR:
354 ata_prtdev(request->device, "WARNING - %s recovered error\n",
355 ata_cmd2str(request));
356 /* FALLTHROUGH */
357
358 case ATA_SK_NO_SENSE:
359 request->result = 0;
360 break;
361
362 case ATA_SK_NOT_READY:
363 request->result = EBUSY;
364 break;
365
366 case ATA_SK_UNIT_ATTENTION:
367 request->device->flags |= ATA_D_MEDIA_CHANGED;
368 request->result = EIO;
369 break;
370
371 default:
372 request->result = EIO;
373 if (request->flags & ATA_R_QUIET)
374 break;
375
376 ata_prtdev(request->device,
377 "FAILURE - %s %s asc=0x%02x ascq=0x%02x ",
378 ata_cmd2str(request), ata_skey2str(
379 (request->u.atapi.sense_key & ATA_SK_MASK) >> 4),
380 request->u.atapi.sense_data.asc,
381 request->u.atapi.sense_data.ascq);
382 if (request->u.atapi.sense_data.sksv)
383 printf("sks=0x%02x 0x%02x 0x%02x ",
384 request->u.atapi.sense_data.sk_specific,
385 request->u.atapi.sense_data.sk_specific1,
386 request->u.atapi.sense_data.sk_specific2);
387 printf("error=%b\n",
388 (request->u.atapi.sense_key & ATA_E_MASK),
389 "\2\4MEDIA_CHANGE_REQUEST\3ABORTED"
390 "\2NO_MEDIA\1ILLEGAL_LENGTH");
391 }
392
393 if ((request->u.atapi.sense_key ?
394 request->u.atapi.sense_key : request->error) & ATA_E_MASK)
395 request->result = EIO;
396 }
397
398 ATA_DEBUG_RQ(request, "completed callback/wakeup");
399
400 /* get results back to the initiator */
401 if (request->callback)
402 (request->callback)(request);
403 else
404 sema_post(&request->done);
405
406 ata_start(ch);
407 }
408
409 static void
410 ata_timeout(struct ata_request *request)
411 {
412 struct ata_channel *ch = request->device->channel;
413
414 mtx_lock(&ch->state_mtx);
415
416 ATA_DEBUG_RQ(request, "timeout");
417
418 /* if interrupt has been seen, shout and just rearm timeout */
419 if (request->flags & ATA_R_INTR_SEEN) {
420 ata_prtdev(request->device,
421 "WARNING - %s interrupt was seen but timeout fired",
422 ata_cmd2str(request));
423 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
424 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
425 printf("\n");
426
427 /* re-arm timeout */
428 if (!dumping)
429 callout_reset(&request->callout, request->timeout * hz,
430 (timeout_t*)ata_timeout, request);
431 mtx_unlock(&ch->state_mtx);
432 return;
433 }
434
435 /*
436 * if we are waiting for a command to complete set ATA_TIMEOUT so
437 * we wont loose the race with an eventual interrupt arriving late
438 */
439 if (ch->state == ATA_ACTIVE) {
440 request->flags |= ATA_R_TIMEOUT;
441 ch->state = ATA_TIMEOUT;
442 ch->running = NULL;
443 if (!(request->flags & ATA_R_QUIET) && request->retries > 0) {
444 ata_prtdev(request->device,
445 "TIMEOUT - %s retrying (%d retr%s left)",
446 ata_cmd2str(request), request->retries,
447 request->retries == 1 ? "y" : "ies");
448 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
449 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
450 printf("\n");
451 }
452 ch->hw.end_transaction(request);
453 mtx_unlock(&ch->state_mtx);
454 ata_finish(request);
455 }
456 else {
457 mtx_unlock(&ch->state_mtx);
458 ata_prtdev(request->device, "timeout state=%d unexpected\n", ch->state);
459 }
460 }
461
462 void
463 ata_catch_inflight(struct ata_channel *ch)
464 {
465 struct ata_request *request;
466
467 mtx_lock(&ch->state_mtx);
468 request = ch->running;
469 ch->running = NULL;
470 mtx_unlock(&ch->state_mtx);
471
472 if (request) {
473 callout_drain(&request->callout);
474 ata_prtdev(request->device,
475 "WARNING - %s requeued due to channel reset",
476 ata_cmd2str(request));
477 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
478 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
479 printf("\n");
480 request->flags |= ATA_R_REQUEUE;
481 ata_queue_request(request);
482 }
483 }
484
485 void
486 ata_fail_requests(struct ata_channel *ch, struct ata_device *device)
487 {
488 struct ata_request *request;
489
490 /* fail all requests queued on this channel */
491 mtx_lock(&ch->queue_mtx);
492 while ((request = TAILQ_FIRST(&ch->ata_queue))) {
493 if (!device || request->device == device) {
494 TAILQ_REMOVE(&ch->ata_queue, request, chain);
495 request->result = ENXIO;
496 if (request->callback)
497 (request->callback)(request);
498 else
499 sema_post(&request->done);
500 }
501 }
502 mtx_unlock(&ch->queue_mtx);
503
504 mtx_lock(&ch->state_mtx);
505 request = ch->running;
506 ch->running = NULL;
507 mtx_unlock(&ch->state_mtx);
508
509 /* if we have a request "in flight" fail it as well */
510 if (request && (!device || request->device == device)) {
511 callout_drain(&request->callout);
512 request->result = ENXIO;
513 if (request->callback)
514 (request->callback)(request);
515 else
516 sema_post(&request->done);
517 }
518 }
519
520 char *
521 ata_cmd2str(struct ata_request *request)
522 {
523 static char buffer[20];
524
525 if (request->flags & ATA_R_ATAPI) {
526 switch (request->u.atapi.sense_key ?
527 request->u.atapi.sense_cmd : request->u.atapi.ccb[0]) {
528 case 0x00: return ("TEST_UNIT_READY");
529 case 0x01: return ("REZERO");
530 case 0x03: return ("REQUEST_SENSE");
531 case 0x04: return ("FORMAT");
532 case 0x08: return ("READ");
533 case 0x0a: return ("WRITE");
534 case 0x10: return ("WEOF");
535 case 0x11: return ("SPACE");
536 case 0x12: return ("INQUIRY");
537 case 0x15: return ("MODE_SELECT");
538 case 0x19: return ("ERASE");
539 case 0x1a: return ("MODE_SENSE");
540 case 0x1b: return ("START_STOP");
541 case 0x1e: return ("PREVENT_ALLOW");
542 case 0x23: return ("ATAPI_READ_FORMAT_CAPACITIES");
543 case 0x25: return ("READ_CAPACITY");
544 case 0x28: return ("READ_BIG");
545 case 0x2a: return ("WRITE_BIG");
546 case 0x2b: return ("LOCATE");
547 case 0x34: return ("READ_POSITION");
548 case 0x35: return ("SYNCHRONIZE_CACHE");
549 case 0x3b: return ("WRITE_BUFFER");
550 case 0x3c: return ("READ_BUFFER");
551 case 0x42: return ("READ_SUBCHANNEL");
552 case 0x43: return ("READ_TOC");
553 case 0x45: return ("PLAY_10");
554 case 0x47: return ("PLAY_MSF");
555 case 0x48: return ("PLAY_TRACK");
556 case 0x4b: return ("PAUSE");
557 case 0x51: return ("READ_DISK_INFO");
558 case 0x52: return ("READ_TRACK_INFO");
559 case 0x53: return ("RESERVE_TRACK");
560 case 0x54: return ("SEND_OPC_INFO");
561 case 0x55: return ("MODE_SELECT_BIG");
562 case 0x58: return ("REPAIR_TRACK");
563 case 0x59: return ("READ_MASTER_CUE");
564 case 0x5a: return ("MODE_SENSE_BIG");
565 case 0x5b: return ("CLOSE_TRACK/SESSION");
566 case 0x5c: return ("READ_BUFFER_CAPACITY");
567 case 0x5d: return ("SEND_CUE_SHEET");
568 case 0xa1: return ("BLANK_CMD");
569 case 0xa3: return ("SEND_KEY");
570 case 0xa4: return ("REPORT_KEY");
571 case 0xa5: return ("PLAY_12");
572 case 0xa6: return ("LOAD_UNLOAD");
573 case 0xad: return ("READ_DVD_STRUCTURE");
574 case 0xb4: return ("PLAY_CD");
575 case 0xbb: return ("SET_SPEED");
576 case 0xbd: return ("MECH_STATUS");
577 case 0xbe: return ("READ_CD");
578 case 0xff: return ("POLL_DSC");
579 }
580 }
581 else {
582 switch (request->u.ata.command) {
583 case 0x00: return ("NOP");
584 case 0x08: return ("ATAPI_RESET");
585 case 0x20: return ("READ");
586 case 0x24: return ("READ48");
587 case 0x25: return ("READ_DMA48");
588 case 0x26: return ("READ_DMA_QUEUED48");
589 case 0x29: return ("READ_MUL48");
590 case 0x30: return ("WRITE");
591 case 0x34: return ("WRITE48");
592 case 0x35: return ("WRITE_DMA48");
593 case 0x36: return ("WRITE_DMA_QUEUED48");
594 case 0x39: return ("WRITE_MUL48");
595 case 0xa0: return ("PACKET_CMD");
596 case 0xa1: return ("ATAPI_IDENTIFY");
597 case 0xa2: return ("SERVICE");
598 case 0xb0: return ("SMART");
599 case 0xc4: return ("READ_MUL");
600 case 0xc5: return ("WRITE_MUL");
601 case 0xc6: return ("SET_MULTI");
602 case 0xc7: return ("READ_DMA_QUEUED");
603 case 0xc8: return ("READ_DMA");
604 case 0xca: return ("WRITE_DMA");
605 case 0xcc: return ("WRITE_DMA_QUEUED");
606 case 0xe6: return ("SLEEP");
607 case 0xe7: return ("FLUSHCACHE");
608 case 0xea: return ("FLUSHCACHE48");
609 case 0xec: return ("ATA_IDENTIFY");
610 case 0xef:
611 switch (request->u.ata.feature) {
612 case 0x03: return ("SETFEATURES SET TRANSFER MODE");
613 case 0x02: return ("SETFEATURES ENABLE WCACHE");
614 case 0x82: return ("SETFEATURES DISABLE WCACHE");
615 case 0xaa: return ("SETFEATURES ENABLE RCACHE");
616 case 0x55: return ("SETFEATURES DISABLE RCACHE");
617 }
618 sprintf(buffer, "SETFEATURES 0x%02x", request->u.ata.feature);
619 return buffer;
620 }
621 }
622 sprintf(buffer, "unknown CMD (0x%02x)", request->u.ata.command);
623 return buffer;
624 }
625
626 static char *
627 ata_skey2str(u_int8_t skey)
628 {
629 switch (skey) {
630 case 0x00: return ("NO SENSE");
631 case 0x01: return ("RECOVERED ERROR");
632 case 0x02: return ("NOT READY");
633 case 0x03: return ("MEDIUM ERROR");
634 case 0x04: return ("HARDWARE ERROR");
635 case 0x05: return ("ILLEGAL REQUEST");
636 case 0x06: return ("UNIT ATTENTION");
637 case 0x07: return ("DATA PROTECT");
638 case 0x08: return ("BLANK CHECK");
639 case 0x09: return ("VENDOR SPECIFIC");
640 case 0x0a: return ("COPY ABORTED");
641 case 0x0b: return ("ABORTED COMMAND");
642 case 0x0c: return ("EQUAL");
643 case 0x0d: return ("VOLUME OVERFLOW");
644 case 0x0e: return ("MISCOMPARE");
645 case 0x0f: return ("RESERVED");
646 default: return("UNKNOWN");
647 }
648 }
Cache object: 5d63702f2ceee897e6575dffce8a1f56
|