diff options
-rw-r--r-- | sys/dev/ata/atapi-all.c | 2 | ||||
-rw-r--r-- | sys/dev/ata/atapi-all.h | 3 | ||||
-rw-r--r-- | sys/dev/ata/atapi-cd.c | 29 |
3 files changed, 19 insertions, 15 deletions
diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c index 05480b2..dc4c99b 100644 --- a/sys/dev/ata/atapi-all.c +++ b/sys/dev/ata/atapi-all.c @@ -226,6 +226,8 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, caddr_t data, await(PRIBIO, 0); splx(s); error = request->error; + if (error) + atp->sense = request->sense; #ifdef ATAPI_DEBUG ata_printf(atp->controller, atp->unit, "finished %s\n", atapi_cmd2str(request->ccb[0])); diff --git a/sys/dev/ata/atapi-all.h b/sys/dev/ata/atapi-all.h index 10263e1..fd7c188 100644 --- a/sys/dev/ata/atapi-all.h +++ b/sys/dev/ata/atapi-all.h @@ -147,6 +147,7 @@ struct atapi_softc { int unit; /* ATA_MASTER or ATA_SLAVE */ void *driver; /* ptr to subdriver softc */ u_int8_t cmd; /* last cmd executed */ + struct atapi_reqsense sense; /* last cmd sense if error */ int flags; /* drive flags */ #define ATAPI_F_MEDIA_CHANGED 0x0001 #define ATAPI_F_DETACHING 0x0002 @@ -166,7 +167,7 @@ struct atapi_request { int result; /* result of this cmd */ int error; /* result translated to errno */ struct atapi_reqsense sense; /* sense data if error */ - int flags; + int flags; #define ATPR_F_READ 0x0001 #define ATPR_F_DMA_USED 0x0002 #define ATPR_F_AT_HEAD 0x0004 diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index 6b10fc9..6b6bab3 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -1540,22 +1540,23 @@ acd_read_track_info(struct acd_softc *cdp, static int acd_get_progress(struct acd_softc *cdp, int *finished) { - int8_t ccb[16] = { ATAPI_REQUEST_SENSE, 0, 0, 0, - sizeof(struct atapi_reqsense), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - struct atapi_reqsense sense; - int error; + int8_t ccb[16] = { ATAPI_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + char tmp[8]; - if ((error = atapi_test_ready(cdp->atp)) != EBUSY) { - *finished = 100; - return error; + if (atapi_test_ready(cdp->atp) != EBUSY) { + if (atapi_queue_cmd(cdp->atp, ccb, tmp, sizeof(tmp), + ATPR_F_READ, 30, NULL, NULL) != EBUSY) { + *finished = 100; + return 0; + } } - - error = atapi_queue_cmd(cdp->atp, ccb, (caddr_t)&sense, sizeof(sense), - ATPR_F_READ, 10, NULL, NULL); - - *finished = ((sense.sk_specific2|(sense.sk_specific1<<8))*100)/65535; - return error; + if (cdp->atp->sense.sksv) + *finished = ((cdp->atp->sense.sk_specific2 | + (cdp->atp->sense.sk_specific1 << 8)) * 100) / 65535; + else + *finished = 0; + return 0; } static int |