2 * Copyright (c) 1998,1999,2000,2001,2002 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.
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.
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.
28 * $FreeBSD: src/sys/dev/ata/atapi-all.c,v 1.46.2.18 2002/10/31 23:10:33 thomas Exp $
29 * $DragonFly: src/sys/dev/disk/ata/atapi-all.c,v 1.20 2006/12/22 23:26:15 swildner Exp $
33 #include "use_atapicd.h"
34 #include "use_atapifd.h"
35 #include "use_atapist.h"
36 #include "use_atapicam.h"
38 #include <sys/param.h>
39 #include <sys/systm.h>
41 #include <sys/kernel.h>
43 #include <sys/malloc.h>
45 #include <sys/sysctl.h>
47 #include <sys/thread2.h>
49 #include <machine/clock.h>
52 #include "atapi-all.h"
55 static void atapi_requeue(struct ata_channel
*chan
, struct atapi_request
*req
);
56 static void atapi_read(struct atapi_request
*, int);
57 static void atapi_write(struct atapi_request
*, int);
58 static void atapi_finish(struct atapi_request
*);
59 static void atapi_timeout(struct atapi_request
*);
60 static char *atapi_cmd2str(u_int8_t
);
61 static char *atapi_skey2str(u_int8_t
);
64 #define ATAPI_MAX_RETRIES 3
67 static int atapi_dma
= 0;
68 TUNABLE_INT("hw.ata.atapi_dma", &atapi_dma
);
69 static MALLOC_DEFINE(M_ATAPI
, "ATAPI generic", "ATAPI driver generic layer");
73 SYSCTL_INT(_hw_ata
, OID_AUTO
, atapi_dma
, CTLFLAG_RD
, &atapi_dma
, 0,
74 "ATAPI device DMA mode control");
77 atapi_attach(struct ata_device
*atadev
, int alreadylocked
)
80 ata_prtdev(atadev
, "piomode=%d dmamode=%d udmamode=%d dmaflag=%d\n",
81 ata_pmode(atadev
->param
), ata_wmode(atadev
->param
),
82 ata_umode(atadev
->param
), atadev
->param
->support_dma
);
85 ATA_SLEEPLOCK_CH(atadev
->channel
, ATA_CONTROL
);
86 if (atapi_dma
&& !(atadev
->param
->drq_type
== ATAPI_DRQT_INTR
)) {
88 (ata_pmode(atadev
->param
) < 0) ?
89 (atadev
->param
->support_dma
? 4:0):ata_pmode(atadev
->param
),
90 (ata_wmode(atadev
->param
) < 0) ?
91 (atadev
->param
->support_dma
? 2:0):ata_wmode(atadev
->param
),
92 ata_umode(atadev
->param
));
96 ata_pmode(atadev
->param
) < 0 ? 0 : ata_pmode(atadev
->param
),
98 ATA_UNLOCK_CH(atadev
->channel
);
100 atadev
->result
= kmalloc(sizeof(struct atapi_reqsense
), M_ATAPI
,
103 switch (atadev
->param
->type
) {
105 case ATAPI_TYPE_CDROM
:
106 if (acdattach(atadev
))
111 case ATAPI_TYPE_DIRECT
:
112 if (afdattach(atadev
))
117 case ATAPI_TYPE_TAPE
:
118 if (astattach(atadev
))
124 ata_prtdev(atadev
, "<%.40s/%.8s> - NO DRIVER!\n",
125 atadev
->param
->model
, atadev
->param
->revision
);
126 kfree(atadev
->result
, M_ATAPI
);
127 atadev
->driver
= NULL
;
132 atapi_detach(struct ata_device
*atadev
)
134 struct atapi_request
*request
;
136 atadev
->flags
|= ATA_D_DETACHING
;
137 ata_prtdev(atadev
, "removed from configuration\n");
138 switch (atadev
->param
->type
) {
140 case ATAPI_TYPE_CDROM
:
145 case ATAPI_TYPE_DIRECT
:
150 case ATAPI_TYPE_TAPE
:
157 TAILQ_FOREACH(request
, &atadev
->channel
->atapi_queue
, chain
) {
158 if (request
->device
!= atadev
)
160 TAILQ_REMOVE(&atadev
->channel
->atapi_queue
, request
, chain
);
161 if (request
->driver
) {
162 struct bio
*bio
= (struct bio
*) request
->driver
;
163 bio
->bio_buf
->b_flags
|= B_ERROR
;
164 bio
->bio_buf
->b_error
= ENXIO
;
168 kfree(request
, M_ATAPI
);
170 kfree(atadev
->result
, M_ATAPI
);
171 atadev
->driver
= NULL
;
177 atapi_queue_cmd(struct ata_device
*atadev
, int8_t *ccb
, caddr_t data
,
178 int count
, int flags
, int timeout
,
179 atapi_callback_t callback
, void *driver
)
181 struct atapi_request
*request
;
184 request
= kmalloc(sizeof(struct atapi_request
), M_ATAPI
, M_INTWAIT
|M_ZERO
);
185 request
->device
= atadev
;
186 request
->data
= data
;
187 request
->bytecount
= count
;
188 request
->flags
= flags
;
189 request
->error
= EINPROGRESS
;
190 request
->timeout
= timeout
* hz
;
191 request
->ccbsize
= atadev
->param
->packet_size
? 16 : 12;
192 callout_init(&request
->callout
);
193 bcopy(ccb
, request
->ccb
, request
->ccbsize
);
195 request
->callback
= callback
;
196 request
->driver
= driver
;
198 if (atadev
->mode
>= ATA_DMA
) {
199 error
= ata_dmaalloc(atadev
, M_WAITOK
);
200 KKASSERT(error
== 0);
204 ata_prtdev(atadev
, "queueing %s ", atapi_cmd2str(request
->ccb
[0]));
205 atapi_dump("ccb = ", &request
->ccb
[0], sizeof(request
->ccb
));
207 /* append onto controller queue and try to start controller */
209 if (flags
& ATPR_F_AT_HEAD
)
210 TAILQ_INSERT_HEAD(&atadev
->channel
->atapi_queue
, request
, chain
);
212 TAILQ_INSERT_TAIL(&atadev
->channel
->atapi_queue
, request
, chain
);
213 ata_start(atadev
->channel
);
215 /* if callback used, then just return, gets called from interrupt context */
221 /* only sleep when command is in progress */
222 if (request
->error
== EINPROGRESS
)
223 tsleep((caddr_t
)request
, 0, "atprq", 0);
225 error
= request
->error
;
227 bcopy(&request
->sense
, atadev
->result
, sizeof(struct atapi_reqsense
));
228 kfree(request
, M_ATAPI
);
233 atapi_start(struct ata_device
*atadev
)
235 switch (atadev
->param
->type
) {
237 case ATAPI_TYPE_CDROM
:
242 case ATAPI_TYPE_DIRECT
:
247 case ATAPI_TYPE_TAPE
:
257 atapi_requeue(struct ata_channel
*chan
, struct atapi_request
*req
)
259 if (req
->donecount
) {
261 "WARNING: atapi resetting donecount %u for retry\n",
263 req
->bytecount
+= req
->donecount
;
266 TAILQ_INSERT_HEAD(&chan
->atapi_queue
, req
, chain
);
270 atapi_transfer(struct atapi_request
*request
)
272 struct ata_device
*atadev
= request
->device
;
277 ata_prtdev(atadev
, "starting %s ", atapi_cmd2str(request
->ccb
[0]));
278 atapi_dump("ccb = ", &request
->ccb
[0], sizeof(request
->ccb
));
280 /* is this just a POLL DSC command ? */
281 if (request
->ccb
[0] == ATAPI_POLL_DSC
) {
282 ATA_OUTB(atadev
->channel
->r_io
, ATA_DRIVE
, ATA_D_IBM
| atadev
->unit
);
284 if (ATA_INB(atadev
->channel
->r_altio
, ATA_ALTSTAT
) & ATA_S_DSC
)
287 request
->error
= EBUSY
;
288 atapi_finish(request
);
289 return ATA_OP_FINISHED
;
292 /* start timeout for this command */
293 callout_reset(&request
->callout
, request
->timeout
,
294 (void *)atapi_timeout
, request
);
296 if (!(request
->flags
& ATPR_F_INTERNAL
))
297 atadev
->cmd
= request
->ccb
[0];
299 /* if DMA enabled setup DMA hardware */
300 request
->flags
&= ~ATPR_F_DMA_USED
;
301 if ((atadev
->mode
>= ATA_DMA
) &&
302 (request
->ccb
[0] == ATAPI_READ
||
303 request
->ccb
[0] == ATAPI_READ_BIG
||
304 request
->ccb
[0] == ATAPI_READ_CD
||
305 ((request
->ccb
[0] == ATAPI_WRITE
||
306 request
->ccb
[0] == ATAPI_WRITE_BIG
) &&
307 !(atadev
->channel
->flags
& ATA_ATAPI_DMA_RO
))) &&
308 !ata_dmasetup(atadev
, (void *)request
->data
, request
->bytecount
)) {
309 request
->flags
|= ATPR_F_DMA_USED
;
312 /* start ATAPI operation */
313 if (ata_command(atadev
, ATA_C_PACKET_CMD
,
314 min(request
->bytecount
, 65534) << 8, 0,
315 (request
->flags
& ATPR_F_DMA_USED
) ? ATA_F_DMA
: 0,
317 ata_prtdev(atadev
, "failure to send ATAPI packet command\n");
319 if (request
->flags
& ATPR_F_DMA_USED
)
320 ata_dmastart(atadev
, request
->data
, request
->bytecount
,
321 request
->flags
& ATPR_F_READ
);
323 /* command interrupt device ? just return */
324 if (atadev
->param
->drq_type
== ATAPI_DRQT_INTR
)
325 return ATA_OP_CONTINUES
;
327 /* ready to write ATAPI command */
328 timout
= 5000; /* might be less for fast devices */
330 reason
= ATA_INB(atadev
->channel
->r_io
, ATA_IREASON
);
331 atadev
->channel
->status
= ATA_INB(atadev
->channel
->r_io
, ATA_STATUS
);
332 if (((reason
& (ATA_I_CMD
| ATA_I_IN
)) |
333 (atadev
->channel
->status
&(ATA_S_DRQ
|ATA_S_BUSY
)))==ATAPI_P_CMDOUT
)
338 ata_prtdev(atadev
, "failure to execute ATAPI packet command\n");
339 callout_stop(&request
->callout
);
340 request
->error
= EIO
;
341 atapi_finish(request
);
342 return ATA_OP_FINISHED
;
345 /* this seems to be needed for some (slow) devices */
348 /* send actual command */
349 ATA_OUTSW(atadev
->channel
->r_io
, ATA_DATA
, (int16_t *)request
->ccb
,
350 request
->ccbsize
/ sizeof(int16_t));
351 return ATA_OP_CONTINUES
;
355 atapi_interrupt(struct atapi_request
*request
)
357 struct ata_device
*atadev
= request
->device
;
358 int reason
, dma_stat
= 0;
360 reason
= (ATA_INB(atadev
->channel
->r_io
, ATA_IREASON
)&(ATA_I_CMD
|ATA_I_IN
))|
361 (atadev
->channel
->status
& ATA_S_DRQ
);
363 if (reason
== ATAPI_P_CMDOUT
) {
364 if (!(atadev
->channel
->status
& ATA_S_DRQ
)) {
365 ata_prtdev(atadev
, "command interrupt without DRQ\n");
366 callout_stop(&request
->callout
);
367 request
->error
= EIO
;
368 atapi_finish(request
);
369 return ATA_OP_FINISHED
;
371 ATA_OUTSW(atadev
->channel
->r_io
, ATA_DATA
, (int16_t *)request
->ccb
,
372 request
->ccbsize
/ sizeof(int16_t));
373 return ATA_OP_CONTINUES
;
376 if (request
->flags
& ATPR_F_DMA_USED
) {
377 dma_stat
= ata_dmadone(atadev
);
378 if ((atadev
->channel
->status
& (ATA_S_ERROR
| ATA_S_DWF
)) ||
379 dma_stat
& ATA_BMSTAT_ERROR
) {
380 request
->result
= ATA_INB(atadev
->channel
->r_io
, ATA_ERROR
);
384 request
->donecount
= request
->bytecount
;
385 request
->bytecount
= 0;
389 int length
= ATA_INB(atadev
->channel
->r_io
, ATA_CYL_LSB
) |
390 ATA_INB(atadev
->channel
->r_io
, ATA_CYL_MSB
) << 8;
394 if (request
->flags
& ATPR_F_READ
) {
395 request
->result
= ATA_INB(atadev
->channel
->r_io
, ATA_ERROR
);
396 ata_prtdev(atadev
, "%s trying to write on read buffer\n",
397 atapi_cmd2str(atadev
->cmd
));
400 atapi_write(request
, length
);
401 return ATA_OP_CONTINUES
;
404 if (!(request
->flags
& ATPR_F_READ
)) {
405 request
->result
= ATA_INB(atadev
->channel
->r_io
, ATA_ERROR
);
406 ata_prtdev(atadev
, "%s trying to read on write buffer\n",
407 atapi_cmd2str(atadev
->cmd
));
410 atapi_read(request
, length
);
411 return ATA_OP_CONTINUES
;
413 case ATAPI_P_DONEDRQ
:
414 ata_prtdev(atadev
, "%s DONEDRQ\n", atapi_cmd2str(atadev
->cmd
));
415 if (request
->flags
& ATPR_F_READ
)
416 atapi_read(request
, length
);
418 atapi_write(request
, length
);
423 if (atadev
->channel
->status
& (ATA_S_ERROR
| ATA_S_DWF
))
424 request
->result
= ATA_INB(atadev
->channel
->r_io
, ATA_ERROR
);
426 if (!(request
->flags
& ATPR_F_INTERNAL
))
431 ata_prtdev(atadev
, "unknown transfer phase %#x:%#x\n",
432 ATA_INB(atadev
->channel
->r_io
, ATA_IREASON
), reason
);
433 request
->result
= ATA_S_ERROR
;
436 callout_stop(&request
->callout
);
438 /* check for error, if valid sense key, queue a request sense cmd */
439 if ((request
->result
& ATAPI_SK_MASK
) &&
440 request
->ccb
[0] != ATAPI_REQUEST_SENSE
) {
441 bzero(request
->ccb
, request
->ccbsize
);
442 request
->ccb
[0] = ATAPI_REQUEST_SENSE
;
443 request
->ccb
[4] = sizeof(struct atapi_reqsense
);
444 request
->bytecount
= sizeof(struct atapi_reqsense
);
445 request
->flags
&= ATPR_F_QUIET
;
446 request
->flags
|= ATPR_F_READ
| ATPR_F_INTERNAL
;
447 TAILQ_INSERT_HEAD(&atadev
->channel
->atapi_queue
, request
, chain
);
450 if (request
->result
) {
451 switch ((request
->result
& ATAPI_SK_MASK
)) {
452 case ATAPI_SK_NO_SENSE
:
456 case ATAPI_SK_RECOVERED_ERROR
:
457 ata_prtdev(atadev
, "%s - recovered error\n",
458 atapi_cmd2str(atadev
->cmd
));
462 case ATAPI_SK_NOT_READY
:
463 request
->error
= EBUSY
;
466 case ATAPI_SK_UNIT_ATTENTION
:
467 atadev
->flags
|= ATA_D_MEDIA_CHANGED
;
468 request
->error
= EIO
;
472 request
->error
= EIO
;
474 if (request
->flags
& ATPR_F_QUIET
)
477 ata_prtdev(atadev
, "%s - %s asc=0x%02x ascq=0x%02x ",
478 atapi_cmd2str(atadev
->cmd
),
479 atapi_skey2str(request
->sense
.sense_key
),
480 request
->sense
.asc
, request
->sense
.ascq
);
481 if (request
->sense
.sksv
)
482 kprintf("sks=0x%02x 0x%02x 0x%02x ",
483 request
->sense
.sk_specific
,
484 request
->sense
.sk_specific1
,
485 request
->sense
.sk_specific2
);
486 kprintf("error=0x%02x\n", request
->result
& ATAPI_E_MASK
);
491 atapi_finish(request
);
493 return ATA_OP_FINISHED
;
497 atapi_reinit(struct ata_device
*atadev
)
499 /* reinit device parameters */
500 if (atadev
->mode
>= ATA_DMA
)
502 (ata_pmode(atadev
->param
) < 0) ?
503 (atadev
->param
->support_dma
? 4:0):ata_pmode(atadev
->param
),
504 (ata_wmode(atadev
->param
) < 0) ?
505 (atadev
->param
->support_dma
? 2:0):ata_wmode(atadev
->param
),
506 ata_umode(atadev
->param
));
509 ata_pmode(atadev
->param
)<0 ? 0 : ata_pmode(atadev
->param
),
514 atapi_test_ready(struct ata_device
*atadev
)
516 int8_t ccb
[16] = { ATAPI_TEST_UNIT_READY
, 0, 0, 0, 0,
517 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
519 return atapi_queue_cmd(atadev
, ccb
, NULL
, 0, 0, 30, NULL
, NULL
);
523 atapi_wait_dsc(struct ata_device
*atadev
, int timeout
)
526 int8_t ccb
[16] = { ATAPI_POLL_DSC
, 0, 0, 0, 0,
527 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
530 while (timeout
> 0) {
531 error
= atapi_queue_cmd(atadev
, ccb
, NULL
, 0, 0, 0, NULL
, NULL
);
534 tsleep((caddr_t
)&error
, 0, "atpwt", hz
/ 2);
541 atapi_dump(char *label
, void *data
, int len
)
545 kprintf("%s %02x", label
, *p
++);
547 kprintf ("-%02x", *p
++);
552 atapi_read(struct atapi_request
*request
, int length
)
554 int8_t **buffer
= (int8_t **)&request
->data
;
555 int size
= min(request
->bytecount
, length
);
556 struct ata_channel
*ch
= request
->device
->channel
;
559 if (request
->flags
& ATPR_F_INTERNAL
)
560 *buffer
= (int8_t *)&request
->sense
;
562 if (ch
->flags
& ATA_USE_16BIT
|| (size
% sizeof(int32_t)))
563 ATA_INSW(ch
->r_io
, ATA_DATA
, (void *)((uintptr_t)*buffer
),
564 size
/ sizeof(int16_t));
566 ATA_INSL(ch
->r_io
, ATA_DATA
, (void *)((uintptr_t)*buffer
),
567 size
/ sizeof(int32_t));
569 if (request
->bytecount
< length
) {
570 ata_prtdev(request
->device
, "read data overrun %d/%d\n",
571 length
, request
->bytecount
);
572 for (resid
=request
->bytecount
; resid
<length
; resid
+=sizeof(int16_t))
573 ATA_INW(ch
->r_io
, ATA_DATA
);
576 request
->bytecount
-= size
;
577 request
->donecount
+= size
;
581 atapi_write(struct atapi_request
*request
, int length
)
583 int8_t **buffer
= (int8_t **)&request
->data
;
584 int size
= min(request
->bytecount
, length
);
585 struct ata_channel
*ch
= request
->device
->channel
;
588 if (request
->flags
& ATPR_F_INTERNAL
)
589 *buffer
= (int8_t *)&request
->sense
;
591 if (ch
->flags
& ATA_USE_16BIT
|| (size
% sizeof(int32_t)))
592 ATA_OUTSW(ch
->r_io
, ATA_DATA
, (void *)((uintptr_t)*buffer
),
593 size
/ sizeof(int16_t));
595 ATA_OUTSL(ch
->r_io
, ATA_DATA
, (void *)((uintptr_t)*buffer
),
596 size
/ sizeof(int32_t));
598 if (request
->bytecount
< length
) {
599 ata_prtdev(request
->device
, "write data underrun %d/%d\n",
600 length
, request
->bytecount
);
601 for (resid
=request
->bytecount
; resid
<length
; resid
+=sizeof(int16_t))
602 ATA_OUTW(ch
->r_io
, ATA_DATA
, 0);
605 request
->bytecount
-= size
;
606 request
->donecount
+= size
;
610 atapi_finish(struct atapi_request
*request
)
613 ata_prtdev(request
->device
, "finished %s%s\n",
614 request
->callback
? "callback " : "",
615 atapi_cmd2str(request
->ccb
[0]));
617 if (request
->callback
) {
618 if (!((request
->callback
)(request
))) {
619 kfree(request
, M_ATAPI
);
623 wakeup((caddr_t
)request
);
627 atapi_timeout(struct atapi_request
*request
)
629 struct ata_device
*atadev
= request
->device
;
631 atadev
->channel
->running
= NULL
;
632 ata_prtdev(atadev
, "%s command timeout - resetting\n",
633 atapi_cmd2str(request
->ccb
[0]));
635 if (request
->flags
& ATPR_F_DMA_USED
) {
637 if (request
->retries
== ATAPI_MAX_RETRIES
) {
639 (ata_pmode(atadev
->param
) < 0) ? 0 :
640 ata_pmode(atadev
->param
), -1, -1);
641 ata_prtdev(atadev
, "trying fallback to PIO mode\n");
642 request
->retries
= 0;
646 /* if retries still permit, reinject this request */
647 if (request
->retries
++ < ATAPI_MAX_RETRIES
) {
648 atapi_requeue(atadev
->channel
, request
);
651 /* retries all used up, return error */
652 request
->error
= EIO
;
653 wakeup((caddr_t
)request
);
655 ata_reinit(atadev
->channel
);
659 atapi_cmd2str(u_int8_t cmd
)
662 case 0x00: return ("TEST_UNIT_READY");
663 case 0x01: return ("REZERO");
664 case 0x03: return ("REQUEST_SENSE");
665 case 0x04: return ("FORMAT_UNIT");
666 case 0x08: return ("READ");
667 case 0x0a: return ("WRITE");
668 case 0x10: return ("WEOF");
669 case 0x11: return ("SPACE");
670 case 0x15: return ("MODE_SELECT");
671 case 0x19: return ("ERASE");
672 case 0x1a: return ("MODE_SENSE");
673 case 0x1b: return ("START_STOP");
674 case 0x1e: return ("PREVENT_ALLOW");
675 case 0x25: return ("READ_CAPACITY");
676 case 0x28: return ("READ_BIG");
677 case 0x2a: return ("WRITE_BIG");
678 case 0x2b: return ("LOCATE");
679 case 0x34: return ("READ_POSITION");
680 case 0x35: return ("SYNCHRONIZE_CACHE");
681 case 0x3b: return ("WRITE_BUFFER");
682 case 0x3c: return ("READ_BUFFER");
683 case 0x42: return ("READ_SUBCHANNEL");
684 case 0x43: return ("READ_TOC");
685 case 0x45: return ("PLAY_10");
686 case 0x47: return ("PLAY_MSF");
687 case 0x48: return ("PLAY_TRACK");
688 case 0x4b: return ("PAUSE");
689 case 0x51: return ("READ_DISK_INFO");
690 case 0x52: return ("READ_TRACK_INFO");
691 case 0x53: return ("RESERVE_TRACK");
692 case 0x54: return ("SEND_OPC_INFO");
693 case 0x55: return ("MODE_SELECT_BIG");
694 case 0x58: return ("REPAIR_TRACK");
695 case 0x59: return ("READ_MASTER_CUE");
696 case 0x5a: return ("MODE_SENSE_BIG");
697 case 0x5b: return ("CLOSE_TRACK/SESSION");
698 case 0x5c: return ("READ_BUFFER_CAPACITY");
699 case 0x5d: return ("SEND_CUE_SHEET");
700 case 0xa1: return ("BLANK_CMD");
701 case 0xa3: return ("SEND_KEY");
702 case 0xa4: return ("REPORT_KEY");
703 case 0xa5: return ("PLAY_12");
704 case 0xa6: return ("LOAD_UNLOAD");
705 case 0xad: return ("READ_DVD_STRUCTURE");
706 case 0xb4: return ("PLAY_CD");
707 case 0xbb: return ("SET_SPEED");
708 case 0xbd: return ("MECH_STATUS");
709 case 0xbe: return ("READ_CD");
710 case 0xff: return ("POLL_DSC");
712 static char buffer
[20];
713 ksprintf(buffer
, "unknown CMD (0x%02x)", cmd
);
720 atapi_skey2str(u_int8_t skey
)
723 case 0x00: return ("NO SENSE");
724 case 0x01: return ("RECOVERED ERROR");
725 case 0x02: return ("NOT READY");
726 case 0x03: return ("MEDIUM ERROR");
727 case 0x04: return ("HARDWARE ERROR");
728 case 0x05: return ("ILLEGAL REQUEST");
729 case 0x06: return ("UNIT ATTENTION");
730 case 0x07: return ("DATA PROTECT");
731 case 0x08: return ("BLANK CHECK");
732 case 0x09: return ("VENDOR SPECIFIC");
733 case 0x0a: return ("COPY ABORTED");
734 case 0x0b: return ("ABORTED COMMAND");
735 case 0x0c: return ("EQUAL");
736 case 0x0d: return ("VOLUME OVERFLOW");
737 case 0x0e: return ("MISCOMPARE");
738 case 0x0f: return ("RESERVED");
739 default: return("UNKNOWN");