Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to program custom ATA/ATAPI commands in Windows/XP?

459 views
Skip to first unread message

talkb

unread,
Feb 5, 2008, 2:14:51 AM2/5/08
to
For an OEM project, I need to send some proprietary commands
to some Compactflash (CF) cards. The CF-cards fully comply with
the CompactFlash Type I spec (so they enumerate, act & look like
a mass-storage volume under Windows/XP.)

At www.ata-atapi.com, Mr. Landis has published some nice (MS-DOS)
C-source code library to perform ATA/ATAPI operations on
the legacy IDE-interface (port I/O 0x1F8.) Unfortunately, that
only works under real-mode MSDOS.

I started reading about organization of the ATA/ATAPI devices under
Windows/XP (atapi.sys? IDE miniport driver) over in the Platform SDK.
But honestly, I'm not a Windows programming expert, and if someone
could narrow down my search, or just tell me, "go find a professional
driver developer", that would help me a lot.

So usingn Visual C++ 6, how would I go about doing something similar
under Windows/XP? I'm hoping this can be done on user/application side,
and not require writing a custom device-driver/port-driver (or whatever
you call it.)


David Craig

unread,
Feb 5, 2008, 3:04:52 AM2/5/08
to
There may be ways to do some requests. There are passthroughs available in
the storage stacks, but they are tricky and don't always work. I have seen
posts from folks at Seagate and others who have to do this kind of thing for
utilities.

"talkb" <no...@talkb.com> wrote in message
news:O1Upj.7044$nK5....@nlpi069.nbdc.sbc.com...

Sam of California

unread,
Feb 18, 2008, 12:56:22 PM2/18/08
to
Hopefully you have an answer by now and I am not sure what you need to do,
but the CreateFile function can open devices and then the device can be
accessed using device-specific commands.


"talkb" <no...@talkb.com> wrote in message
news:O1Upj.7044$nK5....@nlpi069.nbdc.sbc.com...

Don Burn

unread,
Feb 18, 2008, 1:12:47 PM2/18/08
to
For XP you are pretty much out of luck. You may be able to do some stuff
with IOCTL_SCSI_PASS_THROUGH or SMART_RCV_DRIVE_DATA depending on the
particular controller and driver implementation. What you want is
IOCTL_ATA_PASS_THROUGH unfortunately that needs Windows Sever 2003 or Vista
to get it, and even then as David pointed out it can have problems.

--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"David Craig" <dri...@nowhere.us> wrote in message
news:Ot$iK38ZI...@TK2MSFTNGP05.phx.gbl...

arko

unread,
Mar 2, 2008, 2:42:17 PM3/2/08
to
"Don Burn" <bu...@stopspam.windrvr.com> wrote in message
news:Otj%23anlcI...@TK2MSFTNGP06.phx.gbl...

> For XP you are pretty much out of luck. You may be able to do some stuff
> with IOCTL_SCSI_PASS_THROUGH or SMART_RCV_DRIVE_DATA depending on the
> particular controller and driver implementation. What you want is
> IOCTL_ATA_PASS_THROUGH unfortunately that needs Windows Sever 2003 or
> Vista to get it, and even then as David pointed out it can have problems.

Well, you and everyone else were pretty much correct.
I fooled around with Visual C++ 2008 Express Edition, and a sample-program
from
ftp://ftp.heise.de/pub/ct/listings/0207-218.zip
Under Windows/XP, the sample-program WINATA.exe uses IOCTL_IDE_PASS_THROUGH
to get the drive's AAM (Acoustic) info. I couldn't get to that stage, but
the initial ATA "IDENTIFY" command succeeds on some of my drives.

Now here's the weird-part... on Windows XP/Pro SP2 (32-bit), and an
Intel P35/ICH9R motherboard (with onboard Jmicron JMB363 Parallel/ATA):

The Jmicron Parallel/ATA port works with IOCTL_IDE_PASS_THROUGH. The
"IDENTIFY" command successfully returns the drive's name & serial#.
The Intel ICH9R SATA AHCI controller (yes, I'm in AHCI mode) returns blank
info. The return-code indicates success, but the name&serial# aren't
there.
The Jmicron Serial/ATA (AHCI) port fails, it can't identify an attached
drive.

So I modified WINATA.cpp to use IOCTL_ATA_PASS_THROUGH:
Now, the Jmicron Parallel/ATA port fails -- I guess it doesn't support
IOCTL_ATA...
The ICH9R SATA AHCI controller works! It successfully returns
name&serial#.
The Jmicron Serial/ATA (AHCI) still fails.

I probably need to double-check the return-codes and buffer-validation in
the
sample-program.

I guess the next step is to see if I can send *real* Compactflash-ATA
commands
(and not just "ATA IDENTIFY", which every IOCTL probably supports)

...

Anyway, I have 1 more question.
If I start with the PhysicalDrive handle
CreateFile("\\\.\\PhysicalDrive0", ),
how hard is it to traceback to the parent IDE/SCSI host-bus-adapter name?
(For example, if the user selects a physicaldrive, how would a C++ program
determine which ATA/SATA/SCSI HBA it's attached to?)


0 new messages