[haiku-development] Re: harddisk access

  • From: "Euan Kirkhope" <euan.kirkhope@xxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 25 Jul 2007 14:03:18 +0100

I started writing an "ali_ata" driver for my IDE ALI 5229.  Basically
I wanted to apply all the ALI specific hooks that the BSD (in this
case FreeBSD) apply to the ALI hardware.  Specifically the following
that are poked into several registers (the first seemed the most
important to me):

http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/ata/ata-chipset.c?rev=1.126.2.19;content-type=text%2Fplain

from ata_ali_setmode() in ata-chipset.c:

       /* use device interrupt as byte count end */
        pci_write_config(dev, 0x4a, pci_read_config(dev, 0x4a, 1) | 0x20, 1);

        /* enable cable detection and UDMA support on newer chips */
        pci_write_config(dev, 0x4b, pci_read_config(dev, 0x4b, 1) | 0x09, 1);

        /* enable ATAPI UDMA mode */
        pci_write_config(dev, 0x53, pci_read_config(dev, 0x53, 1) | 0x01, 1);

        /* only chips with revision > 0xc4 can do 48bit DMA */
        if (ctlr->chip->chiprev <= 0xc4)
            device_printf(dev,
                          "using PIO transfers above 137GB as workaround for "
                          "48bit DMA access bug, expect reduced performance\n");
        ctlr->allocate = ata_ali_allocate;
        ctlr->reset = ata_ali_reset;
        ctlr->setmode = ata_ali_setmode;
        break;

The other hooks are mostly for ancient buggy implementations on a
couple of proprietary
hardware designs (eg sparc etc), no particularly relevant.

It was sort of based on a munge of the AHCI, and some other driver in
the tree, then I realised that both had subtle difficulties with
regards to the interface that I couldn't resolve.  EG like how to do
simple things like PCI access, how to store private data.  So i
started from scratch based off the generic driver.  In the end I just
started hacking the generic driver, and intended to post the changes
if it worked, and let someone else figure it out.  but i thought that
was mean, and it was never finished anyway, instead I just hard coded
IDE DMA off. :)   I'm not a fan of highly abstract C++ type code.  I
much prefer C, with structures of function pointers for implenting
modularity, but after that I get a bit lost if it's not my code.  I'm
sure I could find my way around the code, but with no documentation it
takes for ever to to piece it together on windows in a dummy visual
studio project.   It's hard enough just trying to patch things
together on the Radeon driver, let alone work on other projects. :)  I
spend all day writing similarly complex and abstract embedded C++ so I
don't have the energy to do it at home it seems.

Euan

Other related posts: