Welcome! Log In Create A New Profile


how to issue ATA command using libata

Posted by afalanga 
how to issue ATA command using libata
June 23, 2015 11:41AM
I'm writing a pass through driver which can be used for ATA drives. To this end, I'm modifying the stock ahci driver to provide some necessary hooks for a higher layer character driver. (I'm thinking about changing this model and just having the modified ahci driver make device nodes in user space, but that's another matter.)

My question now is simple though I'm not sure about the answer. Because I'm modifying the stock ahci driver, I need to understand how to provide libata with what it is expecting. Why should I reinvent the wheel. So, how would I issue an Identify Device command (for example) using the libata framework? What I'm envisioning is something like this:

struct cmd {
uint8_t feature;
uint8_t count;
uint8_t lba;
uint8_t device;
uint8_t command;

struct cmd idfy = { 0, 0, 0, 0, 0xec };
write(fd, &idfy, sizeof(struct idfy));

write_handler(inode, .....);
struct cmd *command = kmalloc(sizeof(struct cmd), GFP_KERNEL);
*command = __copy_from_user(...);
/* put the fields into the appropriate ata_queued_cmd structure */

This is what I'd like to do. Can anyone here explain to me how to actually obtain a struct ata_queued_cmd object and make use of it within the kernel?


Your Email:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 6 plus 2?