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 callout_init_mtx(&request->callout, &ch->state_mtx, CALLOUT_RETURNUNLOCKED);
60 if (!request->callback && !(request->flags & ATA_R_REQUEUE))
61 sema_init(&request->done, 0, "ATA request done");
63 /* in ATA_STALL_QUEUE state we call HW directly (used only during reinit) */
64 if ((ch->state & ATA_STALL_QUEUE) && (request->flags & ATA_R_CONTROL)) {
65 mtx_lock(&ch->state_mtx);
66 ch->running = request;
67 if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
69 if (!request->callback)
70 sema_destroy(&request->done);
71 mtx_unlock(&ch->state_mtx);
74 mtx_unlock(&ch->state_mtx);
76 /* otherwise put request on the locked queue at the specified location */
78 mtx_lock(&ch->queue_mtx);
79 if (request->flags & ATA_R_AT_HEAD)
80 TAILQ_INSERT_HEAD(&ch->ata_queue, request, chain);
81 else if (request->flags & ATA_R_ORDERED)
82 ata_sort_queue(ch, request);
84 TAILQ_INSERT_TAIL(&ch->ata_queue, request, chain);
85 mtx_unlock(&ch->queue_mtx);
86 ATA_DEBUG_RQ(request, "queued");
90 /* if this is a requeued request callback/sleep we're done */
91 if (request->flags & ATA_R_REQUEUE)
94 /* if this is not a callback wait until request is completed */
95 if (!request->callback) {
96 ATA_DEBUG_RQ(request, "wait for completition");
98 sema_timedwait(&request->done, request->timeout * hz * 4)) {
99 device_printf(request->dev,
100 "req=%p %s semaphore timeout !! DANGER Will Robinson !!\n",
101 request, ata_cmd2str(request));
104 sema_destroy(&request->done);
109 ata_controlcmd(device_t dev, u_int8_t command, u_int16_t feature,
110 u_int64_t lba, u_int16_t count)
112 struct ata_request *request = ata_alloc_request();
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 = 1;
123 request->retries = 0;
124 ata_queue_request(request);
125 error = request->result;
126 ata_free_request(request);
132 ata_atapicmd(device_t dev, u_int8_t *ccb, caddr_t data,
133 int count, int flags, int timeout)
135 struct ata_request *request = ata_alloc_request();
136 struct ata_device *atadev = device_get_softc(dev);
141 if ((atadev->param.config & ATA_PROTO_MASK) == ATA_PROTO_ATAPI_12)
142 bcopy(ccb, request->u.atapi.ccb, 12);
144 bcopy(ccb, request->u.atapi.ccb, 16);
145 request->data = data;
146 request->bytecount = count;
147 request->transfersize = min(request->bytecount, 65534);
148 request->flags = flags | ATA_R_ATAPI;
149 request->timeout = timeout;
150 request->retries = 0;
151 ata_queue_request(request);
152 error = request->result;
153 ata_free_request(request);
159 ata_start(device_t dev)
161 struct ata_channel *ch = device_get_softc(dev);
162 struct ata_request *request;
163 struct ata_composite *cptr;
164 int dependencies = 0;
166 /* if we have a request on the queue try to get it running */
167 mtx_lock(&ch->queue_mtx);
168 if ((request = TAILQ_FIRST(&ch->ata_queue))) {
170 /* we need the locking function to get the lock for this channel */
171 if (ATA_LOCKING(dev, ATA_LF_LOCK) == ch->unit) {
173 /* check for composite dependencies */
174 if ((cptr = request->composite)) {
175 mtx_lock(&cptr->lock);
176 if ((request->flags & ATA_R_WRITE) &&
177 (cptr->wr_depend & cptr->rd_done) != cptr->wr_depend) {
180 mtx_unlock(&cptr->lock);
183 /* check we are in the right state and has no dependencies */
184 mtx_lock(&ch->state_mtx);
185 if (ch->state == ATA_IDLE && !dependencies) {
186 ATA_DEBUG_RQ(request, "starting");
187 TAILQ_REMOVE(&ch->ata_queue, request, chain);
188 ch->running = request;
189 ch->state = ATA_ACTIVE;
191 /* if we are the freezing point release it */
192 if (ch->freezepoint == request)
193 ch->freezepoint = NULL;
195 if (ch->hw.begin_transaction(request) == ATA_OP_FINISHED) {
197 ch->state = ATA_IDLE;
198 mtx_unlock(&ch->state_mtx);
199 mtx_unlock(&ch->queue_mtx);
200 ATA_LOCKING(dev, ATA_LF_UNLOCK);
205 mtx_unlock(&ch->state_mtx);
206 mtx_unlock(&ch->queue_mtx);
207 while (!ata_interrupt(ch))
212 mtx_unlock(&ch->state_mtx);
215 mtx_unlock(&ch->queue_mtx);
219 ata_finish(struct ata_request *request)
221 struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
224 * if in ATA_STALL_QUEUE state or request has ATA_R_DIRECT flags set
225 * we need to call ata_complete() directly here (no taskqueue involvement)
228 (ch->state & ATA_STALL_QUEUE) || (request->flags & ATA_R_DIRECT)) {
229 ATA_DEBUG_RQ(request, "finish directly");
230 ata_completed(request, 0);
233 /* put request on the proper taskqueue for completition */
234 if (request->bio && !(request->flags & (ATA_R_THREAD | ATA_R_TIMEOUT))){
235 ATA_DEBUG_RQ(request, "finish bio_taskqueue");
236 bio_taskqueue(request->bio, (bio_task_t *)ata_completed, request);
239 TASK_INIT(&request->task, 0, ata_completed, request);
240 ATA_DEBUG_RQ(request, "finish taskqueue_swi");
241 taskqueue_enqueue(taskqueue_swi, &request->task);
247 ata_completed(void *context, int dummy)
249 struct ata_request *request = (struct ata_request *)context;
250 struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
251 struct ata_device *atadev = device_get_softc(request->dev);
252 struct ata_composite *composite;
254 ATA_DEBUG_RQ(request, "completed entered");
256 /* if we had a timeout, reinit channel and deal with the falldown */
257 if (request->flags & ATA_R_TIMEOUT) {
259 * if reinit succeeds and the device doesn't get detached and
260 * there are retries left we reinject this request
262 if (!ata_reinit(ch->dev) && !request->result &&
263 (request->retries-- > 0)) {
264 if (!(request->flags & ATA_R_QUIET)) {
265 device_printf(request->dev,
266 "TIMEOUT - %s retrying (%d retr%s left)",
267 ata_cmd2str(request), request->retries,
268 request->retries == 1 ? "y" : "ies");
269 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
270 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
273 request->flags &= ~(ATA_R_TIMEOUT | ATA_R_DEBUG);
274 request->flags |= (ATA_R_AT_HEAD | ATA_R_REQUEUE);
275 ATA_DEBUG_RQ(request, "completed reinject");
276 ata_queue_request(request);
280 /* ran out of good intentions so finish with error */
281 if (!request->result) {
282 if (!(request->flags & ATA_R_QUIET)) {
284 device_printf(request->dev, "FAILURE - %s timed out",
285 ata_cmd2str(request));
286 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
288 (unsigned long long)request->u.ata.lba);
292 request->result = EIO;
296 /* if this is a soft ECC error warn about it */
297 /* XXX SOS we could do WARF here */
298 if ((request->status & (ATA_S_CORR | ATA_S_ERROR)) == ATA_S_CORR) {
299 device_printf(request->dev,
300 "WARNING - %s soft error (ECC corrected)",
301 ata_cmd2str(request));
302 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
303 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
307 /* if this is a UDMA CRC error we reinject if there are retries left */
308 if (request->flags & ATA_R_DMA && request->error & ATA_E_ICRC) {
309 if (request->retries-- > 0) {
310 device_printf(request->dev,
311 "WARNING - %s UDMA ICRC error (retrying request)",
312 ata_cmd2str(request));
313 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
314 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
316 request->flags |= (ATA_R_AT_HEAD | ATA_R_REQUEUE);
317 ata_queue_request(request);
323 switch (request->flags & ATA_R_ATAPI) {
327 if (!request->result && request->status & ATA_S_ERROR) {
328 if (!(request->flags & ATA_R_QUIET)) {
329 device_printf(request->dev,
330 "FAILURE - %s status=%b error=%b",
331 ata_cmd2str(request),
332 request->status, "\20\10BUSY\7READY\6DMA_READY"
333 "\5DSC\4DRQ\3CORRECTABLE\2INDEX\1ERROR",
334 request->error, "\20\10ICRC\7UNCORRECTABLE"
335 "\6MEDIA_CHANGED\5NID_NOT_FOUND"
336 "\4MEDIA_CHANGE_REQEST"
337 "\3ABORTED\2NO_MEDIA\1ILLEGAL_LENGTH");
338 if ((request->flags & ATA_R_DMA) &&
339 (request->dmastat & ATA_BMSTAT_ERROR))
340 printf(" dma=0x%02x", request->dmastat);
341 if (!(request->flags & (ATA_R_ATAPI | ATA_R_CONTROL)))
342 printf(" LBA=%llu", (unsigned long long)request->u.ata.lba);
345 request->result = EIO;
351 /* skip if result already set */
355 /* if we have a sensekey -> request sense from device */
356 if (request->error & ATA_SK_MASK &&
357 request->u.atapi.ccb[0] != ATAPI_REQUEST_SENSE) {
358 static u_int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0,
359 sizeof(struct atapi_sense),
360 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
362 request->u.atapi.sense_key = request->error;
363 request->u.atapi.sense_cmd = request->u.atapi.ccb[0];
364 bcopy(ccb, request->u.atapi.ccb, 16);
365 request->data = (caddr_t)&request->u.atapi.sense_data;
366 request->bytecount = sizeof(struct atapi_sense);
367 request->donecount = 0;
368 request->transfersize = sizeof(struct atapi_sense);
369 request->timeout = 5;
370 request->flags &= (ATA_R_ATAPI | ATA_R_QUIET);
371 request->flags |= (ATA_R_READ | ATA_R_AT_HEAD | ATA_R_REQUEUE);
372 ATA_DEBUG_RQ(request, "autoissue request sense");
373 ata_queue_request(request);
377 switch (request->u.atapi.sense_key & ATA_SK_MASK) {
378 case ATA_SK_RECOVERED_ERROR:
379 device_printf(request->dev, "WARNING - %s recovered error\n",
380 ata_cmd2str(request));
383 case ATA_SK_NO_SENSE:
387 case ATA_SK_NOT_READY:
388 request->result = EBUSY;
391 case ATA_SK_UNIT_ATTENTION:
392 atadev->flags |= ATA_D_MEDIA_CHANGED;
393 request->result = EIO;
397 request->result = EIO;
398 if (request->flags & ATA_R_QUIET)
401 device_printf(request->dev,
402 "FAILURE - %s %s asc=0x%02x ascq=0x%02x ",
403 ata_cmd2str(request), ata_skey2str(
404 (request->u.atapi.sense_key & ATA_SK_MASK) >> 4),
405 request->u.atapi.sense_data.asc,
406 request->u.atapi.sense_data.ascq);
407 if (request->u.atapi.sense_data.sksv)
408 printf("sks=0x%02x 0x%02x 0x%02x ",
409 request->u.atapi.sense_data.sk_specific,
410 request->u.atapi.sense_data.sk_specific1,
411 request->u.atapi.sense_data.sk_specific2);
413 (request->u.atapi.sense_key & ATA_E_MASK),
414 "\20\4MEDIA_CHANGE_REQUEST\3ABORTED"
415 "\2NO_MEDIA\1ILLEGAL_LENGTH");
418 if ((request->u.atapi.sense_key ?
419 request->u.atapi.sense_key : request->error) & ATA_E_MASK)
420 request->result = EIO;
423 ATA_DEBUG_RQ(request, "completed callback/wakeup");
425 /* if we are part of a composite operation we need to maintain progress */
426 if ((composite = request->composite)) {
429 mtx_lock(&composite->lock);
431 /* update whats done */
432 if (request->flags & ATA_R_READ)
433 composite->rd_done |= (1 << request->this);
434 if (request->flags & ATA_R_WRITE)
435 composite->wr_done |= (1 << request->this);
437 /* find ready to go dependencies */
438 if (composite->wr_depend &&
439 (composite->rd_done & composite->wr_depend)==composite->wr_depend &&
440 (composite->wr_needed & (~composite->wr_done))) {
441 index = composite->wr_needed & ~composite->wr_done;
444 mtx_unlock(&composite->lock);
446 /* if we have any ready candidates kick them off */
450 for (bit = 0; bit < MAX_COMPOSITES; bit++) {
451 if (index & (1 << bit))
452 ata_start(device_get_parent(composite->request[bit]->dev));
457 /* get results back to the initiator for this request */
458 if (request->callback)
459 (request->callback)(request);
461 sema_post(&request->done);
467 ata_timeout(struct ata_request *request)
469 struct ata_channel *ch = device_get_softc(device_get_parent(request->dev));
471 //request->flags |= ATA_R_DEBUG;
472 ATA_DEBUG_RQ(request, "timeout");
475 * if we have an ATA_ACTIVE request running, we flag the request
476 * ATA_R_TIMEOUT so ata_finish will handle it correctly
477 * also NULL out the running request so we wont loose
478 * the race with an eventual interrupt arriving late
480 if (ch->state == ATA_ACTIVE) {
481 request->flags |= ATA_R_TIMEOUT;
483 mtx_unlock(&ch->state_mtx);
484 ATA_LOCKING(ch->dev, ATA_LF_UNLOCK);
488 mtx_unlock(&ch->state_mtx);
493 ata_fail_requests(device_t dev)
495 struct ata_channel *ch = device_get_softc(device_get_parent(dev));
496 struct ata_request *request;
498 /* do we have any outstanding request to care about ?*/
499 mtx_lock(&ch->state_mtx);
500 if ((request = ch->running) && (!dev || request->dev == dev)) {
501 callout_stop(&request->callout);
506 mtx_unlock(&ch->state_mtx);
508 request->result = ENXIO;
512 /* fail all requests queued on this channel for device dev if !NULL */
513 mtx_lock(&ch->queue_mtx);
514 while ((request = TAILQ_FIRST(&ch->ata_queue))) {
515 if (!dev || request->dev == dev) {
516 TAILQ_REMOVE(&ch->ata_queue, request, chain);
517 mtx_unlock(&ch->queue_mtx);
518 request->result = ENXIO;
520 mtx_lock(&ch->queue_mtx);
523 mtx_unlock(&ch->queue_mtx);
527 ata_get_lba(struct ata_request *request)
529 if (request->flags & ATA_R_ATAPI) {
530 switch (request->u.atapi.ccb[0]) {
532 case ATAPI_WRITE_BIG:
534 return (request->u.atapi.ccb[5]) | (request->u.atapi.ccb[4]<<8) |
535 (request->u.atapi.ccb[3]<<16)|(request->u.atapi.ccb[2]<<24);
538 return (request->u.atapi.ccb[4]) | (request->u.atapi.ccb[3]<<8) |
539 (request->u.atapi.ccb[2]<<16);
545 return request->u.ata.lba;
549 ata_sort_queue(struct ata_channel *ch, struct ata_request *request)
551 struct ata_request *this, *next;
553 this = TAILQ_FIRST(&ch->ata_queue);
555 /* if the queue is empty just insert */
557 if (request->composite)
558 ch->freezepoint = request;
559 TAILQ_INSERT_TAIL(&ch->ata_queue, request, chain);
563 /* dont sort frozen parts of the queue */
565 this = ch->freezepoint;
567 /* if position is less than head we add after tipping point */
568 if (ata_get_lba(request) < ata_get_lba(this)) {
569 while ((next = TAILQ_NEXT(this, chain))) {
571 /* have we reached the tipping point */
572 if (ata_get_lba(next) < ata_get_lba(this)) {
574 /* sort the insert */
576 if (ata_get_lba(request) < ata_get_lba(next))
579 } while ((next = TAILQ_NEXT(this, chain)));
586 /* we are after head so sort the insert before tipping point */
588 while ((next = TAILQ_NEXT(this, chain))) {
589 if (ata_get_lba(next) < ata_get_lba(this) ||
590 ata_get_lba(request) < ata_get_lba(next))
596 if (request->composite)
597 ch->freezepoint = request;
598 TAILQ_INSERT_AFTER(&ch->ata_queue, this, request, chain);
602 ata_cmd2str(struct ata_request *request)
604 static char buffer[20];
606 if (request->flags & ATA_R_ATAPI) {
607 switch (request->u.atapi.sense_key ?
608 request->u.atapi.sense_cmd : request->u.atapi.ccb[0]) {
609 case 0x00: return ("TEST_UNIT_READY");
610 case 0x01: return ("REZERO");
611 case 0x03: return ("REQUEST_SENSE");
612 case 0x04: return ("FORMAT");
613 case 0x08: return ("READ");
614 case 0x0a: return ("WRITE");
615 case 0x10: return ("WEOF");
616 case 0x11: return ("SPACE");
617 case 0x12: return ("INQUIRY");
618 case 0x15: return ("MODE_SELECT");
619 case 0x19: return ("ERASE");
620 case 0x1a: return ("MODE_SENSE");
621 case 0x1b: return ("START_STOP");
622 case 0x1e: return ("PREVENT_ALLOW");
623 case 0x23: return ("ATAPI_READ_FORMAT_CAPACITIES");
624 case 0x25: return ("READ_CAPACITY");
625 case 0x28: return ("READ_BIG");
626 case 0x2a: return ("WRITE_BIG");
627 case 0x2b: return ("LOCATE");
628 case 0x34: return ("READ_POSITION");
629 case 0x35: return ("SYNCHRONIZE_CACHE");
630 case 0x3b: return ("WRITE_BUFFER");
631 case 0x3c: return ("READ_BUFFER");
632 case 0x42: return ("READ_SUBCHANNEL");
633 case 0x43: return ("READ_TOC");
634 case 0x45: return ("PLAY_10");
635 case 0x47: return ("PLAY_MSF");
636 case 0x48: return ("PLAY_TRACK");
637 case 0x4b: return ("PAUSE");
638 case 0x51: return ("READ_DISK_INFO");
639 case 0x52: return ("READ_TRACK_INFO");
640 case 0x53: return ("RESERVE_TRACK");
641 case 0x54: return ("SEND_OPC_INFO");
642 case 0x55: return ("MODE_SELECT_BIG");
643 case 0x58: return ("REPAIR_TRACK");
644 case 0x59: return ("READ_MASTER_CUE");
645 case 0x5a: return ("MODE_SENSE_BIG");
646 case 0x5b: return ("CLOSE_TRACK/SESSION");
647 case 0x5c: return ("READ_BUFFER_CAPACITY");
648 case 0x5d: return ("SEND_CUE_SHEET");
649 case 0xa1: return ("BLANK_CMD");
650 case 0xa3: return ("SEND_KEY");
651 case 0xa4: return ("REPORT_KEY");
652 case 0xa5: return ("PLAY_12");
653 case 0xa6: return ("LOAD_UNLOAD");
654 case 0xad: return ("READ_DVD_STRUCTURE");
655 case 0xb4: return ("PLAY_CD");
656 case 0xbb: return ("SET_SPEED");
657 case 0xbd: return ("MECH_STATUS");
658 case 0xbe: return ("READ_CD");
659 case 0xff: return ("POLL_DSC");
663 switch (request->u.ata.command) {
664 case 0x00: return ("NOP");
665 case 0x08: return ("DEVICE_RESET");
666 case 0x20: return ("READ");
667 case 0x24: return ("READ48");
668 case 0x25: return ("READ_DMA48");
669 case 0x26: return ("READ_DMA_QUEUED48");
670 case 0x29: return ("READ_MUL48");
671 case 0x30: return ("WRITE");
672 case 0x34: return ("WRITE48");
673 case 0x35: return ("WRITE_DMA48");
674 case 0x36: return ("WRITE_DMA_QUEUED48");
675 case 0x39: return ("WRITE_MUL48");
676 case 0x70: return ("SEEK");
677 case 0xa0: return ("PACKET_CMD");
678 case 0xa1: return ("ATAPI_IDENTIFY");
679 case 0xa2: return ("SERVICE");
680 case 0xc0: return ("CFA ERASE");
681 case 0xc4: return ("READ_MUL");
682 case 0xc5: return ("WRITE_MUL");
683 case 0xc6: return ("SET_MULTI");
684 case 0xc7: return ("READ_DMA_QUEUED");
685 case 0xc8: return ("READ_DMA");
686 case 0xca: return ("WRITE_DMA");
687 case 0xcc: return ("WRITE_DMA_QUEUED");
688 case 0xe6: return ("SLEEP");
689 case 0xe7: return ("FLUSHCACHE");
690 case 0xea: return ("FLUSHCACHE48");
691 case 0xec: return ("ATA_IDENTIFY");
693 switch (request->u.ata.feature) {
694 case 0x03: return ("SETFEATURES SET TRANSFER MODE");
695 case 0x02: return ("SETFEATURES ENABLE WCACHE");
696 case 0x82: return ("SETFEATURES DISABLE WCACHE");
697 case 0xaa: return ("SETFEATURES ENABLE RCACHE");
698 case 0x55: return ("SETFEATURES DISABLE RCACHE");
700 sprintf(buffer, "SETFEATURES 0x%02x", request->u.ata.feature);
704 sprintf(buffer, "unknown CMD (0x%02x)", request->u.ata.command);
709 ata_skey2str(u_int8_t skey)
712 case 0x00: return ("NO SENSE");
713 case 0x01: return ("RECOVERED ERROR");
714 case 0x02: return ("NOT READY");
715 case 0x03: return ("MEDIUM ERROR");
716 case 0x04: return ("HARDWARE ERROR");
717 case 0x05: return ("ILLEGAL REQUEST");
718 case 0x06: return ("UNIT ATTENTION");
719 case 0x07: return ("DATA PROTECT");
720 case 0x08: return ("BLANK CHECK");
721 case 0x09: return ("VENDOR SPECIFIC");
722 case 0x0a: return ("COPY ABORTED");
723 case 0x0b: return ("ABORTED COMMAND");
724 case 0x0c: return ("EQUAL");
725 case 0x0d: return ("VOLUME OVERFLOW");
726 case 0x0e: return ("MISCOMPARE");
727 case 0x0f: return ("RESERVED");
728 default: return("UNKNOWN");