Hi all
I have SATA device connected to the system , in that i have installed Red Linux and i want to get the serial number of the hard disk. Usually in PATA we issue identify drive command to get the device details to the port address where it is connected. But incase of SATA how can we issue the commands. what is the structure for sending the commands. Because all the SATA devices detected as SCSI. i dont know how to issue commands to the SATA.
Can anyone help me?
Help in issuing commands to SATA
- piranha
- Member
- Posts: 1391
- Joined: Thu Dec 21, 2006 7:42 pm
- Location: Unknown. Momentum is pretty certain, however.
- Contact:
[url=http://visopsys.org/osdev/index.html]You should search the web, because I found this in about 30 sec. Just scroll down until you see it. I generally have a more mild reaction to stuff like this (when someone asks simple questions that can be answered by looking on google), but you should be careful: There are members (I'm not naming names) here who tell you right away to STFW and RTFM. I will suggest looking at the POSTING RULES post at the top of this forum. Please note, to all you members who do use STFW and friends: I agree fully, and would normally do so, in fact I think it's hilarious, so here:
STFW.
Sarcasm is my second language, since my dad spoke/speaks it all the time, therefore I like the getting angry at things! It's awesome[/url]
Oh, and welcome to these here forums. You'll find that they can be as interesting as a Lizard caught in a fishin' net.
-JL
STFW.
Sarcasm is my second language, since my dad spoke/speaks it all the time, therefore I like the getting angry at things! It's awesome[/url]
Oh, and welcome to these here forums. You'll find that they can be as interesting as a Lizard caught in a fishin' net.
-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
I have found site that tells about sending ATA commands to SATA device using sg ioctl. I have filled the sg structure with the below value. I am running this program in Fedora4
sg_io.interface_id = 'S';
sg_io.cmdp = cdb;
sg_io.cmd_len = sizeof(cdb);
sg_io.dxferp = data_in_buffer;
sg_io.dxfer_len = 512;//data_in_length; //
sg_io.dxfer_direction = SG_DXFER_FROM_DEV;
sg_io.sbp = sense;
sg_io.mx_sb_len = sizeof(sense);
sg_io.timeout = 15000;
and CDB structure is,
cdb[0] = 0x85; // ATA pass-through 12
cdb[1] = (4 << 1); // data-in
cdb[2] = 0x2e; // data-in
cdb[4] = 0x00; // ATA feature ID
cdb[6] = 1; // number of sector
cdb[7] = 0x00; //lba_low >> 8;
cdb[8] = 0x00; //lba_low;
cdb[9] = 0x00; //lba_mid >> 8;
cdb[10] = 0x00; //lba_mid;
cdb[11] = 0x00; //lba_high >> 8;
cdb[12] = 0x00; //lba_high;
cdb[14] = 0xEC; // ATA command ID
I have checked CDB values which i am passing with the document "ATA over scsi standard passthru implementation." I am creating the handle for /dev/sda. After passing the ioctl i am getting wrong values in sense buffer.
sense buffer[0]:0x70
sense buffer[1]:0x00
sense buffer[2]:0x05
sense buffer[3]:0x00
sense buffer[4]:0x00
sense buffer[5]:0x00
sense buffer[6]:0x00
sense buffer[7]:0x06
sense buffer[8]:0x00
sense buffer[9]:0x00
sense buffer[10]:0x00. As per program, these values are not valid. I dont know how they have defined like this. Can anyone help me regarding the sense buffer values.
sg_io.interface_id = 'S';
sg_io.cmdp = cdb;
sg_io.cmd_len = sizeof(cdb);
sg_io.dxferp = data_in_buffer;
sg_io.dxfer_len = 512;//data_in_length; //
sg_io.dxfer_direction = SG_DXFER_FROM_DEV;
sg_io.sbp = sense;
sg_io.mx_sb_len = sizeof(sense);
sg_io.timeout = 15000;
and CDB structure is,
cdb[0] = 0x85; // ATA pass-through 12
cdb[1] = (4 << 1); // data-in
cdb[2] = 0x2e; // data-in
cdb[4] = 0x00; // ATA feature ID
cdb[6] = 1; // number of sector
cdb[7] = 0x00; //lba_low >> 8;
cdb[8] = 0x00; //lba_low;
cdb[9] = 0x00; //lba_mid >> 8;
cdb[10] = 0x00; //lba_mid;
cdb[11] = 0x00; //lba_high >> 8;
cdb[12] = 0x00; //lba_high;
cdb[14] = 0xEC; // ATA command ID
I have checked CDB values which i am passing with the document "ATA over scsi standard passthru implementation." I am creating the handle for /dev/sda. After passing the ioctl i am getting wrong values in sense buffer.
sense buffer[0]:0x70
sense buffer[1]:0x00
sense buffer[2]:0x05
sense buffer[3]:0x00
sense buffer[4]:0x00
sense buffer[5]:0x00
sense buffer[6]:0x00
sense buffer[7]:0x06
sense buffer[8]:0x00
sense buffer[9]:0x00
sense buffer[10]:0x00. As per program, these values are not valid. I dont know how they have defined like this. Can anyone help me regarding the sense buffer values.