From owner-freebsd-bugs Sun Sep 14 12:10:06 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id MAA24466 for bugs-outgoing; Sun, 14 Sep 1997 12:10:06 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.7/8.8.7) id MAA24459; Sun, 14 Sep 1997 12:10:01 -0700 (PDT) Resent-Date: Sun, 14 Sep 1997 12:10:01 -0700 (PDT) Resent-Message-Id: <199709141910.MAA24459@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, "K.J.Koster" Received: from mercury.ukc.ac.uk (mercury.ukc.ac.uk [129.12.21.10]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id MAA24063 for ; Sun, 14 Sep 1997 12:04:03 -0700 (PDT) Received: from kestrel.ukc.ac.uk by mercury.ukc.ac.uk with SMTP (PP); Sun, 14 Sep 1997 20:03:46 +0100 Received: from localhost by kestrel.ukc.ac.uk (5.x/UKC-2.14) id AA18796; Sun, 14 Sep 1997 20:03:45 +0100 Message-Id: Date: Sun, 14 Sep 1997 20:03:45 +0100 (BST) From: "K.J.Koster" To: FreeBSD-gnats-submit@FreeBSD.ORG Subject: i386/4538: byteswapped ATAPI id strings Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >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: >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): , removable, iordis dmesg output after applying fix: wdc0: unit 1 (atapi): , 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