2 * Copyright (c) 1998 - 2006 Søren Schmidt <sos@FreeBSD.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
31 #include <sys/param.h>
32 #include <sys/systm.h>
34 #include <sys/kernel.h>
39 #include <sys/taskqueue.h>
41 #include <machine/bus.h>
43 #include <dev/ata/ata-all.h>
47 static void ata_completed(void *, int);
48 static void ata_sort_queue(struct ata_channel *ch, struct ata_request *request);
49 static char *ata_skey2str(u_int8_t);
52 ata_queue_request(struct ata_request *request)
54 struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
56 /* mark request as virgin (this might be a ATA_R_REQUEUE) */
57 request->result = request->status = request->error = 0;
58 request->parent = device_get_parent(request->dev);
59 callout_init_mtx(&request->callout, &ch->state_mtx, CALLOUT_RETURNUNLOCKED);
61 if (!request->callback && !(request->flags & ATA_R_REQUEUE))
62 sema_init(&request->done, 0, "ATA request done");
64 /* in ATA_STALL_QUEUE state we call HW directly */
65 if ((ch->state & ATA_STALL_QUEUE) && (request->flags & ATA_R_CONTROL)) {
66 mtx_lock(&ch->state_mtx);
67 ch->running = request;
68 if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
70 if (!request->callback)
71 sema_destroy(&request->done);
72 mtx_unlock(&ch->state_mtx);
75 mtx_unlock(&ch->state_mtx);
77 /* otherwise put request on the locked queue at the specified location */
79 mtx_lock(&ch->queue_mtx);
80 if (request->flags & ATA_R_AT_HEAD)
81 TAILQ_INSERT_HEAD(&ch->ata_queue, request, chain);
82 else if (request->flags & ATA_R_ORDERED)
83 ata_sort_queue(ch, request);
85 TAILQ_INSERT_TAIL(&ch->ata_queue, request, chain);
86 mtx_unlock(&ch->queue_mtx);
87 ATA_DEBUG_RQ(request, "queued");
91 /* if this is a requeued request callback/sleep we're done */
92 if (request->flags & ATA_R_REQUEUE)
95 /* if this is not a callback wait until request is completed */
96 if (!request->callback) {
97 ATA_DEBUG_RQ(request, "wait for completition");
99 sema_timedwait(&request->done, request->timeout * hz * 4)) {
100 device_printf(request->dev,
101 "WARNING - %s taskqueue timeout "
102 "- completing request directly\n",
103 ata_cmd2str(request));
104 request->flags |= ATA_R_DANGER1;
105 ata_completed(request, 0);
107 sema_destroy(&request->done);
112 ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature,
113 u_int64_t lba, u_int16_t count)
115 struct ata_request *request = ata_alloc_request();
120 request->u.ata.command = command;
121 request->u.ata.lba = lba;
122 request->u.ata.count = count;
123 request->u.ata.feature = feature;
124 request->flags = ATA_R_CONTROL;
125 request->timeout = 1;
126 request->retries = 0;
127 ata_queue_request(request);
128 error = request->result;
129 ata_free_request(request);
135 ata_atapicmd(device_t dev, u_int8_t *ccb, caddr_t data,
136 int count, int flags, int timeout)
138 struct ata_request *request = ata_alloc_request();
139 struct ata_device *atadev = device_get_softc(dev);
144 if ((atadev->param.config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12)
145 bcopy(ccb, request->u.atapi.ccb, 12);
147 bcopy(ccb, request->u.atapi.ccb, 16);
148 request->data = data;
149 request->bytecount = count;
150 request->transfersize = min(request->bytecount, 65534);
151 request->flags = flags | ATA_R_ATAPI;
152 request->timeout = timeout;
153 request->retries = 0;
154 ata_queue_request(request);
155 error = request->result;
156 ata_free_request(request);
162 ata_start(device_t dev)
164 struct ata_channel *ch = device_get_softc(dev);
165 struct ata_request *request;
166 struct ata_composite *cptr;
167 int dependencies = 0;
169 /* if we have a request on the queue try to get it running */
170 mtx_lock(&ch->queue_mtx);
171 if ((request = TAILQ_FIRST(&ch->ata_queue))) {
173 /* we need the locking function to get the lock for this channel */
174 if (ATA_LOCKING(dev, ATA_LF_LOCK) == ch->unit) {
176 /* check for composite dependencies */
177 if ((cptr = request->composite)) {
178 mtx_lock(&cptr->lock);
179 if ((request->flags & ATA_R_WRITE) &&
180 (cptr->wr_depend & cptr->rd_done) != cptr->wr_depend) {
183 mtx_unlock(&cptr->lock);
186 /* check we are in the right state and has no dependencies */
187 mtx_lock(&ch->state_mtx);
188 if (ch->state == ATA_IDLE && !dependencies) {
189 ATA_DEBUG_RQ(request, "starting");
190 TAILQ_REMOVE(&ch->ata_queue, request, chain);
191 ch->running = request;
192 ch->state = ATA_ACTIVE;
194 /* if we are the freezing point release it */
195 if (ch->freezepoint == request)
196 ch->freezepoint = NULL;
198 if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
200 ch->state = ATA_IDLE;
201 mtx_unlock(&ch->state_mtx);
202 mtx_unlock(&ch->queue_mtx);
203 ATA_LOCKING(dev, ATA_LF_UNLOCK);
208 mtx_unlock(&ch->state_mtx);
209 mtx_unlock(&ch->queue_mtx);
210 while (!ata_interrupt(ch))
215 mtx_unlock(&ch->state_mtx);
218 mtx_unlock(&ch->queue_mtx);
222 ata_finish(struct ata_request *request)
224 struct ata_channel *ch = device_get_softc(request->parent);
227 * if in ATA_STALL_QUEUE state or request has ATA_R_DIRECT flags set
228 * we need to call ata_complete() directly here (no taskqueue involvement)
231 (ch->state & ATA_STALL_QUEUE) || (request->flags & ATA_R_DIRECT)) {
232 ATA_DEBUG_RQ(request, "finish directly");
233 ata_completed(request, 0);
236 /* put request on the proper taskqueue for completition */
237 if (request->bio && !(request->flags & (ATA_R_THREAD | ATA_R_TIMEOUT))){
238 ATA_DEBUG_RQ(request, "finish bio_taskqueue");
239 bio_taskqueue(request->bio, (bio_task_t *)ata_completed, request);
242 TASK_INIT(&request->task, 0, ata_completed, request);
243 ATA_DEBUG_RQ(request, "finish taskqueue_swi");
244 taskqueue_enqueue(taskqueue_swi, &request->task);
250 ata_completed(void *context, int dummy)
252 struct ata_request *request = (struct ata_request *)context;
253 struct ata_channel *ch = device_get_softc(request->parent);
254 struct ata_device *atadev = device_get_softc(request->dev);
255 struct ata_composite *composite;
257 if (request->flags & ATA_R_DANGER2) {
258 device_printf(request->dev,
259 "WARNING - %s freeing taskqueue zombie request\n",
260 ata_cmd2str(request));
261 request->flags &= ~(ATA_R_DANGER1 | ATA_R_DANGER2);
262 ata_free_request(request);
265 if (request->flags & ATA_R_DANGER1)
266 request->flags |= ATA_R_DANGER2
268 ATA_DEBUG_RQ(request, "completed entered");
270 /* if we had a timeout, reinit channel and deal with the falldown */
271 if (request->flags & ATA_R_TIMEOUT) {
273 * if the channel is still present and
274 * reinit succeeds and
275 * the device doesn't get detached and
276 * there are retries left we reinject this request
278 if (ch && !ata_reinit(ch->dev) && !request->result &&
279 (request->retries-- > 0)) {
280 if (!(request->flags & ATA_R_QUIET)) {
281 device_printf(request->dev,
282 "TIMEOUT - %s retrying (%d retr%s left)",
283 ata_cmd2str(request), request->retries,
284 request->retries == 1 ? "y" : "ies");
285 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
286 printf(" LBA=%ju", request->u.ata.lba);
289 request->flags &= ~(ATA_R_TIMEOUT | ATA_R_DEBUG);
290 request->flags |= (ATA_R_AT_HEAD | ATA_R_REQUEUE);
291 ATA_DEBUG_RQ(request, "completed reinject");
292 ata_queue_request(request);
296 /* ran out of good intentions so finish with error */
297 if (!request->result) {
298 if (!(request->flags & ATA_R_QUIET)) {
300 device_printf(request->dev, "FAILURE - %s timed out",
301 ata_cmd2str(request));
302 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
303 printf(" LBA=%ju", request->u.ata.lba);
307 request->result = EIO;
310 else if (!(request->flags & ATA_R_ATAPI) ){
311 /* if this is a soft ECC error warn about it */
312 /* XXX SOS we could do WARF here */
313 if ((request->status & (ATA_S_CORR | ATA_S_ERROR)) == ATA_S_CORR) {
314 device_printf(request->dev,
315 "WARNING - %s soft error (ECC corrected)",
316 ata_cmd2str(request));
317 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
318 printf(" LBA=%ju", request->u.ata.lba);
322 /* if this is a UDMA CRC error we reinject if there are retries left */
323 if (request->flags & ATA_R_DMA && request->error & ATA_E_ICRC) {
324 if (request->retries-- > 0) {
325 device_printf(request->dev,
326 "WARNING - %s UDMA ICRC error (retrying request)",
327 ata_cmd2str(request));
328 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
329 printf(" LBA=%ju", request->u.ata.lba);
331 request->flags |= (ATA_R_AT_HEAD | ATA_R_REQUEUE);
332 ata_queue_request(request);
338 switch (request->flags & ATA_R_ATAPI) {
342 if (!request->result && request->status & ATA_S_ERROR) {
343 if (!(request->flags & ATA_R_QUIET)) {
344 device_printf(request->dev,
345 "FAILURE - %s status=%b error=%b",
346 ata_cmd2str(request),
347 request->status, "\20\10BUSY\7READY\6DMA_READY"
348 "\5DSC\4DRQ\3CORRECTABLE\2INDEX\1ERROR",
349 request->error, "\20\10ICRC\7UNCORRECTABLE"
350 "\6MEDIA_CHANGED\5NID_NOT_FOUND"
351 "\4MEDIA_CHANGE_REQEST"
352 "\3ABORTED\2NO_MEDIA\1ILLEGAL_LENGTH");
353 if ((request->flags & ATA_R_DMA) &&
354 (request->dmastat & ATA_BMSTAT_ERROR))
355 printf(" dma=0x%02x", request->dmastat);
356 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
357 printf(" LBA=%ju", request->u.ata.lba);
360 request->result = EIO;
366 /* skip if result already set */
370 /* if we have a sensekey -> request sense from device */
371 if (request->error & ATA_SK_MASK &&
372 request->u.atapi.ccb[0] != ATAPI_REQUEST_SENSE) {
373 static u_int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0,
374 sizeof(struct atapi_sense),
375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
377 request->u.atapi.sense_key = request->error;
378 request->u.atapi.sense_cmd = request->u.atapi.ccb[0];
379 bcopy(ccb, request->u.atapi.ccb, 16);
380 request->data = (caddr_t)&request->u.atapi.sense_data;
381 request->bytecount = sizeof(struct atapi_sense);
382 request->donecount = 0;
383 request->transfersize = sizeof(struct atapi_sense);
384 request->timeout = 5;
385 request->flags &= (ATA_R_ATAPI | ATA_R_QUIET);
386 request->flags |= (ATA_R_READ | ATA_R_AT_HEAD | ATA_R_REQUEUE);
387 ATA_DEBUG_RQ(request, "autoissue request sense");
388 ata_queue_request(request);
392 switch (request->u.atapi.sense_key & ATA_SK_MASK) {
393 case ATA_SK_RECOVERED_ERROR:
394 device_printf(request->dev, "WARNING - %s recovered error\n",
395 ata_cmd2str(request));
398 case ATA_SK_NO_SENSE:
402 case ATA_SK_NOT_READY:
403 request->result = EBUSY;
406 case ATA_SK_UNIT_ATTENTION:
407 atadev->flags |= ATA_D_MEDIA_CHANGED;
408 request->result = EIO;
412 request->result = EIO;
413 if (request->flags & ATA_R_QUIET)
416 device_printf(request->dev,
417 "FAILURE - %s %s asc=0x%02x ascq=0x%02x ",
418 ata_cmd2str(request), ata_skey2str(
419 (request->u.atapi.sense_key & ATA_SK_MASK) >> 4),
420 request->u.atapi.sense_data.asc,
421 request->u.atapi.sense_data.ascq);
422 if (request->u.atapi.sense_data.sksv)
423 printf("sks=0x%02x 0x%02x 0x%02x ",
424 request->u.atapi.sense_data.sk_specific,
425 request->u.atapi.sense_data.sk_specific1,
426 request->u.atapi.sense_data.sk_specific2);
428 (request->u.atapi.sense_key & ATA_E_MASK),
429 "\20\4MEDIA_CHANGE_REQUEST\3ABORTED"
430 "\2NO_MEDIA\1ILLEGAL_LENGTH");
433 if ((request->u.atapi.sense_key ?
434 request->u.atapi.sense_key : request->error) & ATA_E_MASK)
435 request->result = EIO;
438 ATA_DEBUG_RQ(request, "completed callback/wakeup");
440 /* if we are part of a composite operation we need to maintain progress */
441 if ((composite = request->composite)) {
444 mtx_lock(&composite->lock);
446 /* update whats done */
447 if (request->flags & ATA_R_READ)
448 composite->rd_done |= (1 << request->this);
449 if (request->flags & ATA_R_WRITE)
450 composite->wr_done |= (1 << request->this);
452 /* find ready to go dependencies */
453 if (composite->wr_depend &&
454 (composite->rd_done & composite->wr_depend)==composite->wr_depend &&
455 (composite->wr_needed & (~composite->wr_done))) {
456 index = composite->wr_needed & ~composite->wr_done;
459 mtx_unlock(&composite->lock);
461 /* if we have any ready candidates kick them off */
465 for (bit = 0; bit < MAX_COMPOSITES; bit++) {
466 if (index & (1 << bit))
467 ata_start(device_get_parent(composite->request[bit]->dev));
472 /* get results back to the initiator for this request */
473 if (request->callback)
474 (request->callback)(request);
476 sema_post(&request->done);
478 /* only call ata_start if channel is present */
484 ata_timeout(struct ata_request *request)
486 struct ata_channel *ch = device_get_softc(request->parent);
488 //request->flags |= ATA_R_DEBUG;
489 ATA_DEBUG_RQ(request, "timeout");
492 * if we have an ATA_ACTIVE request running, we flag the request
493 * ATA_R_TIMEOUT so ata_finish will handle it correctly
494 * also NULL out the running request so we wont loose
495 * the race with an eventual interrupt arriving late
497 if (ch->state == ATA_ACTIVE) {
498 request->flags |= ATA_R_TIMEOUT;
499 mtx_unlock(&ch->state_mtx);
500 ATA_LOCKING(ch->dev, ATA_LF_UNLOCK);
504 mtx_unlock(&ch->state_mtx);
509 ata_fail_requests(device_t dev)
511 struct ata_channel *ch = device_get_softc(device_get_parent(dev));
512 struct ata_request *request, *tmp;
513 TAILQ_HEAD(, ata_request) fail_requests;
514 TAILQ_INIT(&fail_requests);
516 /* grap all channel locks to avoid races */
517 mtx_lock(&ch->queue_mtx);
518 mtx_lock(&ch->state_mtx);
520 /* do we have any running request to care about ? */
521 if ((request = ch->running) && (!dev || request->dev == dev)) {
522 callout_stop(&request->callout);
524 request->result = ENXIO;
525 TAILQ_INSERT_TAIL(&fail_requests, request, chain);
528 /* fail all requests queued on this channel for device dev if !NULL */
529 TAILQ_FOREACH_SAFE(request, &ch->ata_queue, chain, tmp) {
530 if (!dev || request->dev == dev) {
531 TAILQ_REMOVE(&ch->ata_queue, request, chain);
532 request->result = ENXIO;
533 TAILQ_INSERT_TAIL(&fail_requests, request, chain);
537 mtx_unlock(&ch->state_mtx);
538 mtx_unlock(&ch->queue_mtx);
540 /* finish up all requests collected above */
541 TAILQ_FOREACH_SAFE(request, &fail_requests, chain, tmp) {
542 TAILQ_REMOVE(&fail_requests, request, chain);
548 ata_get_lba(struct ata_request *request)
550 if (request->flags & ATA_R_ATAPI) {
551 switch (request->u.atapi.ccb[0]) {
553 case ATAPI_WRITE_BIG:
555 return (request->u.atapi.ccb[5]) | (request->u.atapi.ccb[4]<<8) |
556 (request->u.atapi.ccb[3]<<16)|(request->u.atapi.ccb[2]<<24);
559 return (request->u.atapi.ccb[4]) | (request->u.atapi.ccb[3]<<8) |
560 (request->u.atapi.ccb[2]<<16);
566 return request->u.ata.lba;
570 ata_sort_queue(struct ata_channel *ch, struct ata_request *request)
572 struct ata_request *this, *next;
574 this = TAILQ_FIRST(&ch->ata_queue);
576 /* if the queue is empty just insert */
578 if (request->composite)
579 ch->freezepoint = request;
580 TAILQ_INSERT_TAIL(&ch->ata_queue, request, chain);
584 /* dont sort frozen parts of the queue */
586 this = ch->freezepoint;
588 /* if position is less than head we add after tipping point */
589 if (ata_get_lba(request) < ata_get_lba(this)) {
590 while ((next = TAILQ_NEXT(this, chain))) {
592 /* have we reached the tipping point */
593 if (ata_get_lba(next) < ata_get_lba(this)) {
595 /* sort the insert */
597 if (ata_get_lba(request) < ata_get_lba(next))
600 } while ((next = TAILQ_NEXT(this, chain)));
607 /* we are after head so sort the insert before tipping point */
609 while ((next = TAILQ_NEXT(this, chain))) {
610 if (ata_get_lba(next) < ata_get_lba(this) ||
611 ata_get_lba(request) < ata_get_lba(next))
617 if (request->composite)
618 ch->freezepoint = request;
619 TAILQ_INSERT_AFTER(&ch->ata_queue, this, request, chain);
623 ata_cmd2str(struct ata_request *request)
625 static char buffer[20];
627 if (request->flags & ATA_R_ATAPI) {
628 switch (request->u.atapi.sense_key ?
629 request->u.atapi.sense_cmd : request->u.atapi.ccb[0]) {
630 case 0x00: return ("TEST_UNIT_READY");
631 case 0x01: return ("REZERO");
632 case 0x03: return ("REQUEST_SENSE");
633 case 0x04: return ("FORMAT");
634 case 0x08: return ("READ");
635 case 0x0a: return ("WRITE");
636 case 0x10: return ("WEOF");
637 case 0x11: return ("SPACE");
638 case 0x12: return ("INQUIRY");
639 case 0x15: return ("MODE_SELECT");
640 case 0x19: return ("ERASE");
641 case 0x1a: return ("MODE_SENSE");
642 case 0x1b: return ("START_STOP");
643 case 0x1e: return ("PREVENT_ALLOW");
644 case 0x23: return ("ATAPI_READ_FORMAT_CAPACITIES");
645 case 0x25: return ("READ_CAPACITY");
646 case 0x28: return ("READ_BIG");
647 case 0x2a: return ("WRITE_BIG");
648 case 0x2b: return ("LOCATE");
649 case 0x34: return ("READ_POSITION");
650 case 0x35: return ("SYNCHRONIZE_CACHE");
651 case 0x3b: return ("WRITE_BUFFER");
652 case 0x3c: return ("READ_BUFFER");
653 case 0x42: return ("READ_SUBCHANNEL");
654 case 0x43: return ("READ_TOC");
655 case 0x45: return ("PLAY_10");
656 case 0x47: return ("PLAY_MSF");
657 case 0x48: return ("PLAY_TRACK");
658 case 0x4b: return ("PAUSE");
659 case 0x51: return ("READ_DISK_INFO");
660 case 0x52: return ("READ_TRACK_INFO");
661 case 0x53: return ("RESERVE_TRACK");
662 case 0x54: return ("SEND_OPC_INFO");
663 case 0x55: return ("MODE_SELECT_BIG");
664 case 0x58: return ("REPAIR_TRACK");
665 case 0x59: return ("READ_MASTER_CUE");
666 case 0x5a: return ("MODE_SENSE_BIG");
667 case 0x5b: return ("CLOSE_TRACK/SESSION");
668 case 0x5c: return ("READ_BUFFER_CAPACITY");
669 case 0x5d: return ("SEND_CUE_SHEET");
670 case 0x96: return ("SERVICE_ACTION_IN");
671 case 0xa1: return ("BLANK_CMD");
672 case 0xa3: return ("SEND_KEY");
673 case 0xa4: return ("REPORT_KEY");
674 case 0xa5: return ("PLAY_12");
675 case 0xa6: return ("LOAD_UNLOAD");
676 case 0xad: return ("READ_DVD_STRUCTURE");
677 case 0xb4: return ("PLAY_CD");
678 case 0xbb: return ("SET_SPEED");
679 case 0xbd: return ("MECH_STATUS");
680 case 0xbe: return ("READ_CD");
681 case 0xff: return ("POLL_DSC");
685 switch (request->u.ata.command) {
686 case 0x00: return ("NOP");
687 case 0x08: return ("DEVICE_RESET");
688 case 0x20: return ("READ");
689 case 0x24: return ("READ48");
690 case 0x25: return ("READ_DMA48");
691 case 0x26: return ("READ_DMA_QUEUED48");
692 case 0x29: return ("READ_MUL48");
693 case 0x30: return ("WRITE");
694 case 0x34: return ("WRITE48");
695 case 0x35: return ("WRITE_DMA48");
696 case 0x36: return ("WRITE_DMA_QUEUED48");
697 case 0x39: return ("WRITE_MUL48");
698 case 0x70: return ("SEEK");
699 case 0xa0: return ("PACKET_CMD");
700 case 0xa1: return ("ATAPI_IDENTIFY");
701 case 0xa2: return ("SERVICE");
702 case 0xc0: return ("CFA ERASE");
703 case 0xc4: return ("READ_MUL");
704 case 0xc5: return ("WRITE_MUL");
705 case 0xc6: return ("SET_MULTI");
706 case 0xc7: return ("READ_DMA_QUEUED");
707 case 0xc8: return ("READ_DMA");
708 case 0xca: return ("WRITE_DMA");
709 case 0xcc: return ("WRITE_DMA_QUEUED");
710 case 0xe6: return ("SLEEP");
711 case 0xe7: return ("FLUSHCACHE");
712 case 0xea: return ("FLUSHCACHE48");
713 case 0xec: return ("ATA_IDENTIFY");
715 switch (request->u.ata.feature) {
716 case 0x03: return ("SETFEATURES SET TRANSFER MODE");
717 case 0x02: return ("SETFEATURES ENABLE WCACHE");
718 case 0x82: return ("SETFEATURES DISABLE WCACHE");
719 case 0xaa: return ("SETFEATURES ENABLE RCACHE");
720 case 0x55: return ("SETFEATURES DISABLE RCACHE");
722 sprintf(buffer, "SETFEATURES 0x%02x", request->u.ata.feature);
726 sprintf(buffer, "unknown CMD (0x%02x)", request->u.ata.command);
731 ata_skey2str(u_int8_t skey)
734 case 0x00: return ("NO SENSE");
735 case 0x01: return ("RECOVERED ERROR");
736 case 0x02: return ("NOT READY");
737 case 0x03: return ("MEDIUM ERROR");
738 case 0x04: return ("HARDWARE ERROR");
739 case 0x05: return ("ILLEGAL REQUEST");
740 case 0x06: return ("UNIT ATTENTION");
741 case 0x07: return ("DATA PROTECT");
742 case 0x08: return ("BLANK CHECK");
743 case 0x09: return ("VENDOR SPECIFIC");
744 case 0x0a: return ("COPY ABORTED");
745 case 0x0b: return ("ABORTED COMMAND");
746 case 0x0c: return ("EQUAL");
747 case 0x0d: return ("VOLUME OVERFLOW");
748 case 0x0e: return ("MISCOMPARE");
749 case 0x0f: return ("RESERVED");
750 default: return("UNKNOWN");