Native ATAPI MO driver

Jason Harmening jason.harmening at gmail.com
Sun Oct 30 19:16:56 PST 2005


On Monday 24 October 2005 11:27, Søren 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øren Schmidt
> sos at FreeBSD.org


I finally managed to find some documentation from Fujitsu, and it turns out my 
drive (and older Fujitsu MO drives as well) use exactly the same capabilities 
page and page code that are already defined in atapi-fd.h.  The reason my 
drive was failing afd_sense() was that by default it returns an 8-byte block 
descriptor between the header and the actual page.  But there's a Disable 
Block Descriptor bit at byte1, bit3 of the MODE SENSE command that will 
prevent it from doing this if set.  It looks like the ATAPI floppies and 
earlier MO drives just ignored this bit and never returned the block 
descriptor.  So I just changed the second character in the command array in 
afd_sense() from 0 to 8, added ATA_ATAPI_TYPE_OPTICAL to afd_probe(), and the 
drive now works as afd0.

From what I've seen, the DBD bit seems to be a standard part of the MODE SENSE 
command block, so I don't think having it set will mess with any of the other 
drives supported by atapifd.  

Reading, writing, deleting, prevent/allow eject, and newfs (UFS2) all work 
with the drive as afd0--haven't tried anything else yet.  

Jason Harmening


More information about the freebsd-hackers mailing list