Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Help writing low level libata device driver

    This is my first attempt writing a low level SATA driver for the libata subsystem, and I am finding it extremely confusing. I can not find a single example implementation that I can actually follow, and what little documentation there is has not been helping.

    I was hoping there was someone who could help me understand essentially what is happening in this code, and point me to a clear example of what I need to do.

    I want my driver to include some useful debugging tools, such as usage statistics and a builtin protocol analyzer, which I understand will be handled mainly via qc_prep and qc_issue. But that is where my understanding hits a brick wall. Let's take a simple case as an example, the IDENTIFY DEVICE command. Now, I know what needs to happen at the SATA level.

    I need to send a host to device FIS with the IDENTIFY command to the device. The device will respond with a PIO SETUP FIS, which includes the transfer size among other things. It should always be 512 in this case. Finally, I will get a DATA FIS from the device with 512 bytes of information.

    Can someone walk me through the functions in a real libata driver and show me where each of these packets is being sent and received, and how libata is parsing them? I would appreciate seeing actual code that builds and parses the FIS structures since that will give me a known reference point to start from.

    I think if I can get my head around this one, I should be able to figure out the rest on my own.

    Thank you for any assistance,


  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Good luck! Anyway, check out this book from O'Reilly for Linux kernel programming: Linux Device Drivers, Third Edition - it is available for free download in PDF form. I leave it as an exercise for you to find it. I find it is invaluable for this sort of job.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts