Date: Sun, 14 Sep 1997 20:03:45 +0100 (BST) From: "K.J.Koster" <kjk1@ukc.ac.uk> To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: i386/4538: byteswapped ATAPI id strings Message-ID: <Pine.SV4.3.95.970914200044.18738A-100000@kestrel.ukc.ac.uk> Resent-Message-ID: <199709141910.MAA24459@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 4538 >Category: i386 >Synopsis: byteswapped ATAPI id strings >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Sep 14 12:10:00 PDT 1997 >Last-Modified: >Originator: Kees Jan Koster >Organization: <Organization of PR author (multiple lines)> >Release: FreeBSD 2.2.2-RELEASE i386 >Environment: Motherboard: DataExpert 8661 cdrom player: BTC 8x ATAPI previous cdrom player: Pioneer 4x ATAPI dmesg output before applying fix: wdc0: unit 1 (atapi): <DCX8 1F 0100- 99169./EP1P1.B>, removable, iordis dmesg output after applying fix: wdc0: unit 1 (atapi): <CD8X F10 01-09 1996. /PEP1.1>, removable, iordis >Description: The ID string and the revision strings come out byteswapped. It happened to both my pioneer and my btc drive. The BIOS autodetection also identifies the cdrom player with its bytes swapped, so I blame my BIOS. It annoyed me, so I propose the following kernel config option: options SWAB_ATAPI_ID >How-To-Repeat: n/a ============================================================== Patch for the LINT kernel (/sys/i386/conf/LINT) ============================================================== *** LINT.orig Sun Sep 14 18:19:19 1997 --- LINT Sun Sep 14 18:23:38 1997 *************** *** 641,646 **** --- 641,653 ---- options ATAPI #Enable ATAPI support for IDE bus options ATAPI_STATIC #Don't do it as an LKM + # + # In some cases, the ID and revision strings of the ATAPI device come out + # byteswapped. Use this option to swap them back. This option is purely + # cosmetic and has no influence on the operation of the device. + # + options SWAB_ATAPI_ID #Byteswap the ID and revision strings + # IDE CD-ROM driver - requires wdc controller and ATAPI option device wcd0 ============================================================== Patch for the atapi driver (/sys/i386/isa/atapi.c): ============================================================== *** atapi.c.orig Fri Jan 17 17:02:33 1997 --- atapi.c Sun Sep 14 18:14:34 1997 *************** *** 173,178 **** --- 173,202 ---- extern int wdstart (int ctrlr); extern int wcdattach(struct atapi*, int, struct atapi_params*, int); + #ifdef SWAB_ATAPI_ID + /* copied verbatim from swap.c in the library sources */ + static void + swab(const void *from, void *to, size_t len) + { + register unsigned long temp; + register int n; + register char *fp, *tp; + + n = (len >> 1) + 1; + fp = (char *)from; + tp = (char *)to; + #define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp + /* round to multiple of 8 */ + while ((--n) & 07) + STEP; + n >>= 3; + while (--n >= 0) { + STEP; STEP; STEP; STEP; + STEP; STEP; STEP; STEP; + } + } + #endif + /* * Probe the ATAPI device at IDE controller `ctlr', drive `unit'. * Called at splbio(). *************** *** 193,204 **** if (! ap) return (0); bcopy (ap->model, buf, sizeof(buf)-1); buf[sizeof(buf)-1] = 0; bcopy (ap->revision, revbuf, sizeof(revbuf)-1); revbuf[sizeof(revbuf)-1] = 0; ! printf ("wdc%d: unit %d (atapi): <%s/%s>", ctlr, unit, buf, revbuf); /* device is removable */ --- 217,235 ---- if (! ap) return (0); + #ifdef SWAB_ATAPI_ID + swab (ap->model, buf, sizeof(buf)-1); + buf[sizeof(buf)-1] = 0; + + swab (ap->revision, revbuf, sizeof(revbuf)-1); + revbuf[sizeof(revbuf)-1] = 0; + #else bcopy (ap->model, buf, sizeof(buf)-1); buf[sizeof(buf)-1] = 0; bcopy (ap->revision, revbuf, sizeof(revbuf)-1); revbuf[sizeof(revbuf)-1] = 0; ! #endif printf ("wdc%d: unit %d (atapi): <%s/%s>", ctlr, unit, buf, revbuf); /* device is removable */ ============================================================== Suggested addition to the handbook and to the wcd manual page: ============================================================== (in the section covering device wcd?) In some cases, the ID and revision strings of the ATAPI device come out byteswapped. Use this option to swap them back. This option is purely cosmetic and has no influence on the operation of the device. >Fix: >Audit-Trail: >Unformatted: X-send-pr-version: 3.2
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SV4.3.95.970914200044.18738A-100000>