Switch to full style
Data recovery and disk repair questions and discussions related to old-fashioned SATA, SAS, SCSI, IDE, MFM hard drives - any type of storage device that has moving parts
Post a reply

ATA commands programming on Windows & Linux

September 3rd, 2009, 0:33

Hey guys,

I am willing to write a code in win32 on windows or in gcc on Linux. Actually i am novice in this HDD ATA thing and thought will gain knowledge by programming some ATA stuff. :)

Now, my problems are,
1.How to by pass Windows HAL to get direct access to HDD SA
2.Which win32 API's should be used to read/write on SA
( I have tried DeviceIOControl & ioctl but havnt got much out of that :shock: )
3.In order to read/write using ATA command set what kind of programming mechanism should be used ?
(Is there any recommended way)
4.Can any one share some sample code to read/write HDD with ATA commands? (please)

Re: ATA commands programming on Windows & Linux

September 3rd, 2009, 16:21

It would be best to use Assembler. If you want you can always use your High level language of choice to make things look pretty. Also do a search here on the forum and u will find more information. You can also find some links to some ATA sample code. SA requires proprietary information, so that's a totally different story.

Best of Luck

Re: ATA commands programming on Windows & Linux

September 3rd, 2009, 21:20

The main question here is how to access IO ports...
In windows it is pretty tricky, either u have to build a driver that runs on ring0, or use some prog that opens access to a specified range of IO ports.
IOCTL calls might be another choice, but it sometimes doesn't work as it should

pepe

Re: ATA commands programming on Windows & Linux

September 3rd, 2009, 22:05

What about Tx/Rx the ATA commands directly from your program to a microcontroller (you program controller in assembler of course) via serial port (RS232 /usb). This way you interface with drive in a manner similarly to other hardware DR tools?

Re: ATA commands programming on Windows & Linux

September 3rd, 2009, 22:51

When sending commands via Tx /Rx are you not limited to terminal communication?
What would be the benefit of doing this rather then sending the commands in asm to the registers passing through the IDE/SATA interface?

Re: ATA commands programming on Windows & Linux

September 4th, 2009, 7:56

I was thinking of a simple, quick PCB with serial port or usb (using max232 or other), microcontroller, and IDE connector. This project might start out very simply, but you could add power controls later if you like. I was not talking about serial port to HDD but rather serial/usb -> ide. Not original at all, done a million times, but good to learn and develop i think. Only need a few cheap ICs and programmer to make it...

Re: ATA commands programming on Windows & Linux

September 4th, 2009, 9:22

Ok, Got it, i miss understood because of the Tx /Rx.
Sounds like a fun project :D
Post a reply