summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>1998-06-09 13:29:59 +0000
committerNiels Provos <provos@cvs.openbsd.org>1998-06-09 13:29:59 +0000
commit8aefe96db719527f8ba0ba227b0059735c44b3d7 (patch)
tree17bd4df4334d417bc74ad74cbfb023372656ca3f /sys/dev
parentfa1411b56cc334a0103c46a3977cb3f9e42e9b9c (diff)
Autodetect ATAPI CDROMS which do not support the ATAPI_READ_CD_CAPACITY
and fake it (meaning add AQUIRK_NOCAPACITY). Also add an entry for NEC CD Changer reported by W. Scholten <wouters@cistron.nl>.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/atapi/acd.c14
-rw-r--r--sys/dev/atapi/atapiconf.c8
2 files changed, 18 insertions, 4 deletions
diff --git a/sys/dev/atapi/acd.c b/sys/dev/atapi/acd.c
index 3243989750b..43273d1cd5a 100644
--- a/sys/dev/atapi/acd.c
+++ b/sys/dev/atapi/acd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acd.c,v 1.29 1997/10/18 10:37:06 deraadt Exp $ */
+/* $OpenBSD: acd.c,v 1.30 1998/06/09 13:29:57 provos Exp $ */
/*
* Copyright (c) 1996 Manuel Bouyer. All rights reserved.
@@ -1101,6 +1101,7 @@ acd_size(acd, flags)
{
struct atapi_read_cd_capacity_data rdcap;
struct atapi_read_cd_capacity cmd;
+ int result;
if (acd->ad_link->quirks & AQUIRK_NOCAPACITY) {
/*
@@ -1125,8 +1126,15 @@ acd_size(acd, flags)
* If the command works, interpret the result as a 4 byte
* number of blocks and a blocksize
*/
- if (atapi_exec_cmd(acd->ad_link, &cmd, sizeof(cmd),
- &rdcap, sizeof(rdcap), B_READ, 0) != 0) {
+ result = atapi_exec_cmd(acd->ad_link, &cmd, sizeof(cmd),
+ &rdcap, sizeof(rdcap), B_READ, 0);
+ if (result != 0) {
+ u_int8_t error = result >> 8;
+ /* Get the sense key and check for an illegal request */
+ if ((error >> 4) == ATAPI_SK_ILLEGAL_REQUEST) {
+ acd->ad_link->quirks |= AQUIRK_NOCAPACITY;
+ return acd_size(acd, flags);
+ }
ATAPI_DEBUG_PRINT(("ATAPI_READ_CD_CAPACITY failed\n"));
return 0;
}
diff --git a/sys/dev/atapi/atapiconf.c b/sys/dev/atapi/atapiconf.c
index f3fe55d59b5..41ce88c12b4 100644
--- a/sys/dev/atapi/atapiconf.c
+++ b/sys/dev/atapi/atapiconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: atapiconf.c,v 1.21 1998/01/02 18:22:07 provos Exp $ */
+/* $OpenBSD: atapiconf.c,v 1.22 1998/06/09 13:29:58 provos Exp $ */
/*
* Copyright (c) 1996 Manuel Bouyer. All rights reserved.
@@ -105,6 +105,9 @@ struct atapi_quirk_inquiry_pattern atapi_quirk_inquiry_patterns[] = {
/* NEC 273 */
{ATAPI_DEVICE_TYPE_CD, ATAPI_REMOVABLE,
"NEC CD-ROM DRIVE:273", "4.21", AQUIRK_NOTUR},
+ /* NEC 4CD changer CDR-C251 */
+ {ATAPI_DEVICE_TYPE_CD, ATAPI_REMOVABLE,
+ "NEC CD-ROM DRIVE:251", "4.14", AQUIRK_NOCAPACITY},
/* Sanyo 4x */
{ATAPI_DEVICE_TYPE_CD, ATAPI_REMOVABLE,
"SANYO CRD-254P", "1.02", AQUIRK_NOCAPACITY},
@@ -355,6 +358,9 @@ atapi_exec_cmd(ad_link, cmd, cmd_size, databuf, datalen, rw, flags)
atapi_free_pkt(pkt);
}
+ if ((pkt->status & ERROR) && (pkt->error))
+ status |= pkt->error << 8;
+
return status;
}