Onkar, First thing you need to learn is not to Top Post. I'll let you research it, but it is basically taboo on lkml lists, so you will get flamed if you do it on one of the official lists. My answers below: On Wed, Apr 7, 2010 at 1:49 AM, Onkar Mahajan <kern.devel@xxxxxxxxx> wrote: > Greg, > My intention is to learn to write a SATA driver with the hardware > that I have. I have a SATA hard drive from Western Digital (MDL : > WD800JD-75MSAS) > and SATA controller (Intel 82801 GB/GR/GH ( ICH7 family ) for which the > drivers are already > present. I want to unload the drivers and reverse engineer them and make > them working. > Is it a good way to learn SATA/SCSI drivers ?? Please guide me with your > invaluable experience. > > Regards, > Onkar A little background. First a little about SCSI: SCSI is a layered protocol stack not too different than TCP/IP. There is actually SCSI-1, SCSI-2, and SCSI-3. I believe those correlate directly with layers 1, 2, 3 of the 7 layer network protocol stack that I assume you are familiar with from TCP/IP type networking. >From the inception of libata (the new ata driver that is in 2.6.x kernels) it has been part of the scsi subsystem and I believe replaces SCSI-1 and SCSI-2, but uses SCSI-3 from the scsi stack itself. That is why sata drives are name /dev/sda etc. fyi: usb does this to, but usb actually uses scsi-2 on the wire. Then within the external drive enclosure is a SAT. (Scsi to ATA translator). So at the connection medium layer (replacing SCSI-1) we have the sata cable and associated voltages. I'll assume you don't care much about that. At the messaging layer (replacing scsi-2) we have the sata spec. uhhh.. I mean we have the portion of the ATA-7 spec. associated with sata devices. You will definitely want to get your hands on a RFC version of the ATA-7 spec. Or even the ATA-8 spec. which has been seeing a lot of work in the last couple years. I don't know if it was ever finalized. I've posted a link to the ATA-8 draft spec. a few times but don't have it handy right now. fyi: I think most of the changes in ATA-8 relate to SSDs and your asking about traditional rotating disk, so ATA-7 should be sufficient. If you want to experiment with sata messaging, I'd suggest you look at hdparm. Its on sourceforge and Mark Lord keeps it pretty current. It can send a large number of the sata messages. I don't think it can send commands that actually update a sector with data. So it is mostly about the command and control, not payload. Ok, now to a little more comparison to networking. I assume you know in the LAN world we have NICs, switches, and destination computers (ie. more nics). In the sata world we have analogous items: NIC => Sata Controller Switch => Port Multiplier destination computer => hard drive So your request for a hdd spec. is sort of like being in the networking world and saying "I want to write a TCP/IP driver, can some one tell me where I can find the Win2008 spec. so I know how to talk to it?" Not very logical, right. At some point you may have to add a "quirk" in to your nic driver to support a weird behavior in the Win2008 stack, but it is by no means where you would start. libata works the same. The core libata driver handles the sata messaging protocol for talking to disks and is implemented to follow the ata-7 spec. So for most hard drives they should just work and no extra coding is needed at all. But, within the libata framework are sata controller drivers, just as within the network portion of linux there are NIC drivers. So what you need primarily are the sata spec (ata-7) and the controller spec. I hope that at least explains things enough to let you try to read the kernel code and begin to learn the libata subsystem. Greg -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ