From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 31 03:16:56 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 41AB416A420 for ; Mon, 31 Oct 2005 03:16:56 +0000 (GMT) (envelope-from jason.harmening@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.202]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0694243D46 for ; Mon, 31 Oct 2005 03:16:54 +0000 (GMT) (envelope-from jason.harmening@gmail.com) Received: by zproxy.gmail.com with SMTP id 40so754247nzk for ; Sun, 30 Oct 2005 19:16:54 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:to:subject:date:user-agent:cc:references:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:message-id:from; b=Wi9rlsHJQN4bEBp4qlpNaljWvpdT2vZNlVFC5y9TDsqbaV25wZUHo/GRdbRnr3tUEKXrynclNSRpdhs1ET7rTOHSIZUzL/+0pjW9TxGTa48wtBDUj6MC9q7daGqf6ZkE8SNoyKgoB+xS2mO7PyFrYciNrdTO0dCv0Ddi54HRN6E= Received: by 10.36.129.4 with SMTP id b4mr2219113nzd; Sun, 30 Oct 2005 19:16:54 -0800 (PST) Received: from ?192.168.0.3? ( [70.112.17.171]) by mx.gmail.com with ESMTP id i5sm2078302nzi.2005.10.30.19.16.53; Sun, 30 Oct 2005 19:16:53 -0800 (PST) To: =?iso-8859-1?q?S=F8ren_Schmidt?= Date: Sun, 30 Oct 2005 21:17:04 -0600 User-Agent: KMail/1.8.2 References: <200510232049.16352.Jason.Harmening@gmail.com> <08AD1F28-AE42-4C36-B5E0-3E909130BDB8@FreeBSD.org> In-Reply-To: <08AD1F28-AE42-4C36-B5E0-3E909130BDB8@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200510302117.04602.Jason.Harmening@gmail.com> From: Jason Harmening X-Mailman-Approved-At: Mon, 31 Oct 2005 12:48:40 +0000 Cc: freebsd-hackers@freebsd.org Subject: Re: Native ATAPI MO driver X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Oct 2005 03:16:56 -0000 On Monday 24 October 2005 11:27, S=F8ren Schmidt wrote: > On 24/10/2005, at 3:49, Jason Harmening wrote: > > Hi, > > > > I have a 2.3G Fujitsu MO drive, and I've gotten tired of using > > atapicam to > > access it. I'm thinking of writing a native ATAPI driver that > > could be added > > to the kernel through a configuration line like: > > > > device atapimo > > > > I've been doing a little work to see how feasible this is--the > > kernel already > > defines the ATA_ATAPI_TYPE_OPTICAL device type that is received > > from my drive > > during probing. But ATA_ATAPI_TYPE_OPTICAL isn't actually used > > anywhere, and > > there is no driver that can actually recognize and attach to an > > ATAPI MO > > drive. > > > > I modified the atapifd driver (src/sys/dev/ata/atapi-fd.c) to also > > recognize > > ATA_ATAPI_TYPE_OPTICAL, and my drive was actually recognized during > > probing > > as afd0, but afd_attach returned an error. It looks as if afd_sense > > () was > > failing, which I'm guessing is because ATAPI MO drives (or mine, at > > least) > > use a different capabilities page code and/or capabilities page > > structure > > than ATAPI floppies. The atapi-fd driver uses 0x5 for its > > "Capabilities and > > Mechanical Status" page code, while everything else (atapi-cd, > > atapi-tape) > > uses 0x2a. All three drivers have distinctly different structures > > for this > > page. > > > > So I'm wondering: do ATAPI MO drives use a capabilities page code/ > > structure > > more like CD/DVD drives, or do they have their own unique ATAPI page > > structure? If so, where can I find a document outlining the > > structure? > > > > I've found loads of documents detailing the page structure for CD/ > > DVD drives, > > but nothing for MO drives (or floppies or tape drives for that > > matter). > > > > Also, beyond the capabilities page, are there any other special > > considerations > > I'd need to make for an MO driver? > > I did plan to write such a driver back when, but HW seemed to have > disappeared from all the vendors I've asked so it was pu ton the > backburner. > Anyhow I should have the docs somewhere so it should be possible to > get this working... > > S=F8ren Schmidt > sos@FreeBSD.org I finally managed to find some documentation from Fujitsu, and it turns out= my=20 drive (and older Fujitsu MO drives as well) use exactly the same capabiliti= es=20 page and page code that are already defined in atapi-fd.h. The reason my=20 drive was failing afd_sense() was that by default it returns an 8-byte bloc= k=20 descriptor between the header and the actual page. But there's a Disable=20 Block Descriptor bit at byte1, bit3 of the MODE SENSE command that will=20 prevent it from doing this if set. It looks like the ATAPI floppies and=20 earlier MO drives just ignored this bit and never returned the block=20 descriptor. So I just changed the second character in the command array in= =20 afd_sense() from 0 to 8, added ATA_ATAPI_TYPE_OPTICAL to afd_probe(), and t= he=20 drive now works as afd0. =46rom what I've seen, the DBD bit seems to be a standard part of the MODE = SENSE=20 command block, so I don't think having it set will mess with any of the oth= er=20 drives supported by atapifd. =20 Reading, writing, deleting, prevent/allow eject, and newfs (UFS2) all work= =20 with the drive as afd0--haven't tried anything else yet. =20 Jason Harmening