Date: Mon, 28 Aug 1995 23:59:35 +0400 From: vak@gw.cronyx.msk.su (Serge V.Vakulenko) To: current@freebsd.org Subject: [patch] version 1.3 of ATAPI CD-ROM driver Message-ID: <199508281959.XAA09453@gw.cronyx.msk.su>
next in thread | raw e-mail | index | archive | help
Hi, This patch upgrades the ATAPI CD-ROM driver to version 1.3. It has three bugs fixed: 1) The `controller not ready' message at startup and later. It was caused by staled media change bit. 2) Incorrect shuffling of model string for some drives (NEC, Mitsumi). 3) Handling of drives which report itself as been of direct-access type, instead of CD-ROM type. There is one known bug which is not fixed yet -- probing in absense of IDE disks. A work-around exists though (thanks Steve!). If you have no IDE disks attached, then remove them from the kernel config file to make the CD-ROM attach correctly. Unfortunately, there is no way to disable them from the kernel interactive config mode. For all who has problems with the drive probing: please, set "#define DEBUG" at the beginning of atapi.c, recompile and reinstall the kernel, reboot and then send me the output of dmesg. I will try to solve it. Regards, Serge diff -u -r ../wcd11/atapi.c ./atapi.c --- ../wcd11/atapi.c Mon Jul 10 22:09:08 1995 +++ ./atapi.c Mon Aug 28 22:07:43 1995 @@ -11,7 +11,7 @@ * or modify this software as long as this message is kept with the software, * all derivative works or modified versions. * - * Version 1.1, Mon Jul 10 21:55:11 MSD 1995 + * Version 1.3, Mon Aug 28 21:44:01 MSD 1995 */ /* @@ -101,7 +101,6 @@ #include "wd.h" #include "wcd.h" -/* #include "whd.h" -- add your driver here */ /* #include "wmt.h" -- add your driver here */ /* #include "wmd.h" -- add your driver here */ @@ -248,6 +247,8 @@ printf ("wdc%d: unit %d: unknown ATAPI type=%d\n", ctlr, unit, ap->devtype); break; + + case AT_TYPE_DIRECT: /* direct-access */ case AT_TYPE_CDROM: /* CD-ROM device */ #if NWCD > 0 /* ATAPI CD-ROM */ @@ -263,13 +264,7 @@ printf ("wdc%d: ATAPI CD-ROMs not configured\n", ctlr); break; #endif - case AT_TYPE_DIRECT: /* direct-access (magnetic disk) */ -#if NWHD > 0 - /* Add your driver here */ -#else - printf ("wdc%d: ATAPI hard disks not supported\n", ctlr); - break; -#endif + case AT_TYPE_TAPE: /* streaming tape (QIC-121 model) */ #if NWMT > 0 /* Add your driver here */ @@ -277,6 +272,7 @@ printf ("wdc%d: ATAPI streaming tapes not supported yet\n", ctlr); break; #endif + case AT_TYPE_OPTICAL: /* optical disk */ #if NWMD > 0 /* Add your driver here */ @@ -336,10 +332,15 @@ return (0); bcopy (tb, ap, sizeof *ap); - /* Shuffle string byte order. */ - for (i=0; i<sizeof(ap->model); i+=2) { - u_short *p = (u_short*) (ap->model + i); - *p = ntohs (*p); + /* + * Shuffle string byte order. + * Mitsumi and NEC drives don't need this. + */ + if (! ((ap->model[0] == 'N' && ap->model[1] == 'E') || + (ap->model[0] == 'F' && ap->model[1] == 'X'))) { + u_short *p = (u_short*) (ap->model + sizeof(ap->model)); + while (--p >= (u_short*) ap->model) + *p = ntohs (*p); } /* Clean up the model by converting nulls to spaces, and @@ -580,12 +581,13 @@ u_char ireason; u_short len; - if (atapi_wait (ata->port, ac->count ? ARS_DRQ : 0) < 0) { - printf ("atapi%d.%d: controller not ready\n", - ata->ctrlr, ac->unit); + if (atapi_wait (ata->port, 0) < 0) { + ac->result.status = inb (ata->port + AR_STATUS); + ac->result.error = inb (ata->port + AR_ERROR); ac->result.code = RES_NOTRDY; - ac->result.status = 0; - ac->result.error = 0; + printf ("atapi%d.%d: controller not ready, status=%b, error=%b\n", + ata->ctrlr, ac->unit, ac->result.status, ARS_BITS, + ac->result.error, AER_BITS); return (0); } diff -u -r ../wcd11/wcd.c ./wcd.c --- ../wcd11/wcd.c Mon Jul 10 22:09:08 1995 +++ ./wcd.c Mon Aug 28 22:07:32 1995 @@ -12,7 +12,7 @@ * or modify this software as long as this message is kept with the software, * all derivative works or modified versions. * - * Version 1.1, Mon Jul 10 21:55:11 MSD 1995 + * Version 1.2, Mon Jul 24 17:21:25 MSD 1995 */ /* @@ -262,10 +262,16 @@ } /* Get drive capabilities. */ + /* Do it twice to avoid the stale media changed state. */ result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE, 0, CAP_PAGE, 0, 0, 0, 0, sizeof (t->cap) >> 8, sizeof (t->cap), 0, 0, 0, 0, 0, 0, 0, (char*) &t->cap, sizeof (t->cap)); + if (result.code == RES_ERR && result.error == AER_SK_UNIT_ATTENTION) + result = atapi_request_immediate (ata, unit, ATAPI_MODE_SENSE, + 0, CAP_PAGE, 0, 0, 0, 0, sizeof (t->cap) >> 8, + sizeof (t->cap), 0, 0, 0, 0, 0, 0, 0, + (char*) &t->cap, sizeof (t->cap)); if (result.code == 0) { wcd_describe (t); if (t->flags & F_DEBUG) @@ -367,14 +373,12 @@ result = atapi_request_wait (t->ata, t->unit, ATAPI_TEST_UNIT_READY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - if (result.code == RES_ERR && result.error == AER_SK_UNIT_ATTENTION) + if (result.code == RES_ERR && result.error == AER_SK_UNIT_ATTENTION) { t->flags |= F_MEDIA_CHANGED; - - if (result.code) result = atapi_request_wait (t->ata, t->unit, ATAPI_TEST_UNIT_READY, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - + } if (result.code) { wcd_error (t, result); return (ENXIO);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199508281959.XAA09453>