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,