ATA_PASS_THROUGH call from User application

Hi All,

I am using ATA_PASS_THROUGH support in XP to send vender specific smart
commands from user application.

If there are two or more IDE controllers, how to determine which IDE
controller sending the ATA_PASS_THROUGH call.

Any suggestions? Thanks in advance.

Regards, Shakeel.

“shakeel” wrote in message news:xxxxx@ntdev…
>
> Hi All,
>
> I am using ATA_PASS_THROUGH support in XP to send vender specific smart
> commands from user application.

First, do you have the ATAPI hotfix that has this support in it? It’s not
there in XP SP1, so if you don’t have the updated driver, it’s not going to
work.

> If there are two or more IDE controllers, how to determine which IDE
> controller sending the ATA_PASS_THROUGH call.

Only those ATA HBA driven by ATAPI.sys are going to work with this.
Promise, or Silicon Image, for two examples, are driven by their own SCSI
miniport drivers, and don’t have this in it. So if you have an add-in PCI
HBA, you probably can ignore that one, but not always.

The brute force method is to just loop through \.\PhysicalDriveN, sending
each an IDENTIFY DEVICE, and dealing with the ones that answer back. Gross,
but effective.

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
E-mail address is pointed at a domain squatter. Use reply-to instead.

Thanks philip,

Yes, I am using the hotfix release of ATAPI.SYS for XP.
that is how I was doing is by opening handle to \physicalDriveN and
sending the ATA PASS THROUGH call.

We provide ATA RAID solution. there will be 2 or more of cards in the
system. I wrote upper class filter driver that provide IOCTLS to get “ATA
Card Count” and “Cards PCI bus, device, function number”

Now, I am writting APIs for our GUI. GUI sends only the cardID ( rages
from Zero to CardCount -1) and IDE regs content to pass down. The problem
is how to determine which card to send ATA_PASS_THROUGH call.

Is there any other way?

Thanks, Shakeel.

“shakeel” wrote in message news:xxxxx@ntdev…
>
> Thanks philip,
>
> Yes, I am using the hotfix release of ATAPI.SYS for XP.
> that is how I was doing is by opening handle to \physicalDriveN and
> sending the ATA PASS THROUGH call.

>
> We provide ATA RAID solution. there will be 2 or more of cards in the
> system. I wrote upper class filter driver that provide IOCTLS to get “ATA
> Card Count” and “Cards PCI bus, device, function number”

You’re writing a software RAID that uses someone else’s HBA? Microsoft beat
you to it, at least in the Server products. I don’t remember at the moment
which software RAIDs, if any, are supported in Windows 2000 Server that
aren’t supported in XP Pro. But NT has had software RADI since NT 3.51, at
least, and I think from the very beginning.

Is your filter above all class drivers, or just the disk class driver? Do
you sit above or below FTDISK?

> Now, I am writting APIs for our GUI. GUI sends only the cardID ( rages
> from Zero to CardCount -1) and IDE regs content to pass down. The problem
> is how to determine which card to send ATA_PASS_THROUGH call.

Where does this GUI call go? To your filter? Your API server determines
which cardID represents which HBA. You have to give the GUI enough
information to select the proper cardID for the HBA the user wants.

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
E-mail address is pointed at a domain squatter. Use reply-to instead.

> aren’t supported in XP Pro. But NT has had software RADI since NT 3.51, at

least, and I think from the very beginning.

Since NT3.1.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Once again Thanks philip,

Sorry! for not being clear, I should have said it in a better way.
We are actually ATA RAID Chip Company and also make HBAs. The GUI
application that runs on windows to Configure/manage our ATA RAID.

As I said before that there will be two or more of our HBAs depending on
the customer’s requirement. The windows see each of our HBA as a
Dual-Channel IDE controller.

I am writing the low level APIs for the GUI to allow it to send vender
specific SMART commands. Initially, I thought I would use the
ATA_PASS_THROUGH support from the user mode by opening handle to
\physicaldriveN as you also have mentioned earlier.

The problem with that is, DDK documentation for ATA_PASS_THROUGH says that
the PathId, TargetId, and Lun, members are filled by the ATAPI.SYS port
driver. So, we don’t get to specify which HBA (I mean IDE controller)?
which Channel (primary/secondary)? which device?

So, I thought I would implement upper class (hdc) filter driver that sits
right on top of ATAPI.SYS (NOT disk class filter) and detects number of
our HBAs and return there PCI Bus, Device number to GUI application. Then,
the GUI can send that as an ID to identify which HBA and specify Channel
number. with this I can’t use ATA_PASS_THROUGH from here right? The
ATAPI.SYS won’t let us specify PathId, TargetId, and Lun, members are
filled by the ATAPI.SYS itself.

Are there any undocumented calls like ATA_PASS_THROUGH where we can also
specify which HBA? which channel?

Thanks in advance,
Shakeel.

I believe if you open a handle to \physicaldriveN and send it an ATA
pass-through command, the path/target/lun values will be filled in by
the ata port driver for the drive you’ve selected.

If you want to send ATA controls to a different device, you would open
that different device and send the ioctls there.

What is your filter driver providing that the system doesn’t already do?

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of shakeel
Sent: Thursday, October 16, 2003 10:51 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: ATA_PASS_THROUGH call from User application

Once again Thanks philip,

Sorry! for not being clear, I should have said it in a better way.
We are actually ATA RAID Chip Company and also make HBAs. The GUI
application that runs on windows to Configure/manage our ATA RAID.

As I said before that there will be two or more of our HBAs depending on
the customer’s requirement. The windows see each of our HBA as a
Dual-Channel IDE controller.

I am writing the low level APIs for the GUI to allow it to send vender
specific SMART commands. Initially, I thought I would use the
ATA_PASS_THROUGH support from the user mode by opening handle to
\physicaldriveN as you also have mentioned earlier.

The problem with that is, DDK documentation for ATA_PASS_THROUGH says
that the PathId, TargetId, and Lun, members are filled by the ATAPI.SYS
port driver. So, we don’t get to specify which HBA (I mean IDE
controller)?
which Channel (primary/secondary)? which device?

So, I thought I would implement upper class (hdc) filter driver that
sits right on top of ATAPI.SYS (NOT disk class filter) and detects
number of our HBAs and return there PCI Bus, Device number to GUI
application. Then, the GUI can send that as an ID to identify which HBA
and specify Channel number. with this I can’t use ATA_PASS_THROUGH from
here right? The ATAPI.SYS won’t let us specify PathId, TargetId, and
Lun, members are filled by the ATAPI.SYS itself.

Are there any undocumented calls like ATA_PASS_THROUGH where we can also
specify which HBA? which channel?

Thanks in advance,
Shakeel.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to xxxxx@lists.osr.com

Peter,

The GUI is designed to Configure/Manage ATA RAID and remember I said there
will be two or more of our ATA RAID HBAs and windows see each one of them
as a Dual-channel IDE controller. having said this,

I am writting APIs at the very bottom layer, the requirements are

  1. Detect the number of HBAs and return the count.
  2. Return the PCI bus, device number for the card (Card number is input
    parameter and is zero based 0,1,… CardCount-1)
  3. Read/Write to the IDE registers, input parameters are Card number
    (HBA)and Channel type (primary/secondary). For this I thought I would use
    ATA_PASS_THROUGH, but the ATAPI won’t let us specify which HBA? which
    Channnel?

That is why I thought of implementing a filter driver that calls either
port driver atapi.sys or IDE controller driver to pciide.sys to write to
the IDE Registers and allow us specify HBA, Channel type, device. I don’t
know how. Are there undocumented IOCTLs to do this?

Peter, correct me if there is better approach than this one.

Thanks I appreciate your help,
Shakeel.

“shakeel” wrote in message news:xxxxx@ntdev…
>
> Peter,
>
> The GUI is designed to Configure/Manage ATA RAID and remember I said there
> will be two or more of our ATA RAID HBAs and windows see each one of them
> as a Dual-channel IDE controller. having said this,

Are you writing the driver for your HBA, or have you implemented it as a
PCI-IDE HBA, so you can use the IDE mini-driver architecture? If you are
writing a driver, are you writing a SCSI miniport, or a full port driver?
If you are letting ATAPI.sys drive your device (the IDE minidriver model),
how do you expect to implement the RAID functionality?

> I am writting APIs at the very bottom layer, the requirements are
> 1. Detect the number of HBAs and return the count.
> 2. Return the PCI bus, device number for the card (Card number is input
> parameter and is zero based 0,1,… CardCount-1)
> 3. Read/Write to the IDE registers, input parameters are Card number
> (HBA)and Channel type (primary/secondary). For this I thought I would use
> ATA_PASS_THROUGH, but the ATAPI won’t let us specify which HBA? which
> Channnel?

What bottom layer? (see my questions above) If you are trying to use
ATAPI.sys to drive a RAID as a RAID, and not just a JABOD, I don’t think you
can. But I defer to Peter or another Microsoft employee on that one.

> That is why I thought of implementing a filter driver that calls either
> port driver atapi.sys or IDE controller driver to pciide.sys to write to
> the IDE Registers and allow us specify HBA, Channel type, device. I don’t
> know how. Are there undocumented IOCTLs to do this?

If you want to manage a RAID HBA, I think you are going to have to write a
SCSI miniport, at minimum.

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
E-mail address is pointed at a domain squatter. Use reply-to instead.

Hi Philip,

Yes you are right. SCSI miniport driver(for IDE) is our long term
solution.

currently we are relying on Microsoft supplied IDE driver stack. However,
We need something quicker solution so that we can test our GUI
application. ATA_PASS_THROUGH does allow to read/write to the IDE
registers but, the ATAPI won’t let us specify HBA, Channel, device number.
That is why the filter driver is all about. Please read my previous mail.

Thanks for your help,
Shakeel.

“shakeel” wrote in message news:xxxxx@ntdev…
>
> Hi Philip,
>
> Yes you are right. SCSI miniport driver(for IDE) is our long term
> solution.
>
> currently we are relying on Microsoft supplied IDE driver stack. However,
> We need something quicker solution so that we can test our GUI
> application. ATA_PASS_THROUGH does allow to read/write to the IDE
> registers but, the ATAPI won’t let us specify HBA, Channel, device number.
> That is why the filter driver is all about. Please read my previous mail.

Is this a hardware RAID or not? I’m having a very hard time imagining how
you are going to tell the RAID to create a RAID 5 stripe set on half the
drive (as an example), if all you have is the ability to send PIO commands
(You do know that ATA_PASS_THROUGH doesn’t do DMA at this time, right?) to a
particular device attached to the HBA.

You say you are intending to do a driver in the long-term. As far as I can
tell from what you’ve written before, that’s the only way you are going to
be able to use the RAID as a RAID. ATAPI.sys doesn’t do RAIDs, it does
PCI-IDE HBAs. Those are NOT THE SAME.

Unless I’m completely wrong about what you are trying to do, you are wasting
your time trying to make ATAPI.sys do what I think you are asking.
ATAPI.sys doesn’t expose any significant access to the HBA, it mostly
exposes a limited API to each device attached to the HBA. Since you appear
to be trying to control the HBA, and not the device, I think you will have
little success.

However, if you persist in chasing this goose, at least pay attention to
what Peter wrote. You have to open a handle to an ATA device to use
ATA_PASS_THROUGH. You open that handle by CreateFile() on
\.\PhysicalDriveN, or the alternative is to use the SetupDi API to
enumerate the instances of the disk interface (not setup) GUID. You can get
a reliable name to use to open a handle to the device. In either case, you
end up with a handle to the device, not the HBA. And any handle to the HBA
won’t execute ATA_PASS_THROUGH commands.

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
E-mail address is pointed at a domain squatter. Use reply-to instead.

> ATA_PASS_THROUGH support from the user mode by opening handle to

\physicaldriveN as you also have mentioned earlier.

The problem with that is, DDK documentation for ATA_PASS_THROUGH says that
the PathId, TargetId, and Lun, members are filled by the ATAPI.SYS port
driver. So, we don?t get to specify which HBA (I mean IDE controller)?
which Channel (primary/secondary)? which device?

Strange question. The device will be \.\physicaldriveN. The disk you
mentioned. Its HBA/channel numbers are automatically substituted by Windows.

ATAPI.SYS won?t let us specify PathId, TargetId, and Lun, members are

You must not. Just specify what disk.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> I am writting APIs at the very bottom layer, the requirements are

  1. Detect the number of HBAs and return the count.
  2. Return the PCI bus, device number for the card (Card number is input
    parameter and is zero based 0,1,… CardCount-1)
  3. Read/Write to the IDE registers, input parameters are Card number
    (HBA)and Channel type (primary/secondary). For this I thought I would use
    ATA_PASS_THROUGH, but the ATAPI won’t let us specify which HBA? which
    Channnel?

Extremely abysmal design.

RAID stuff works with disks. So, just list all ATA-connected disks in a listbox
together with their vendor/product ID from IDENTIFY data and channel numbers.
This only requires SetupDiGetClassDevs and some IOCTL_STORAGE_QUERY_PROPERTY.

After this, send ATA passthrough to a disk device handle.

Do not even bother with things like PCI address of the controller. Not
necessary.

Also it is a good idea to drop the MS’s ATAPI.SYS, and use SCSIPORT instead
like HighPoint does - yes, a SCSI miniport for the IDE RAID chip. Then, to send
RAID management commands, you have IOCTL_SCSI_MINIPORT and custom CDBs.

port driver atapi.sys or IDE controller driver to pciide.sys to write to
the IDE Registers and allow us specify HBA, Channel type, device.

This is a bad idea. Just specify the disk you want to work with. Its Channel
and HBA will be determined automatically.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Once again Thanks to NT Gurus Philip, Max and Peter for resolving and
recomending to go with SCSI Miniport(IDE RAID) as a solution.

Are there resources available that will help me start writing SCSI
Miniport driver (for IDE RAID)? I looked at DDK, it has sample code for
SCSI miniport (for SCSI RAID). Any other resources?

Thanks and Regards,
Shakeel.

> Are there resources available that will help me start writing SCSI

Miniport driver (for IDE RAID)? I looked at DDK, it has sample code for
SCSI miniport (for SCSI RAID). Any other resources?

Yes. This sample code and the documentation.

They are enough to comprehend how the interaction with SCSIPORT works. The rest
is specific for your hardware.

What SCSI commands must be mapped to IDE operations: INQUIRY to IDENTIFY, READ
CAPACITY emulated from IDENTIFY data, rigid geometry mode page can also be
emulated, power management spindown by START STOP UNIT, and READ/WRITE/VERIFY.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

If you don’t need to do anything extraordinary, those samples and the
documentation in the DDK, should be sufficient.


Gary G. Little
Seagate Technologies, LLC

“shakeel” wrote in message news:xxxxx@ntdev…
>
>
> Once again Thanks to NT Gurus Philip, Max and Peter for resolving and
> recomending to go with SCSI Miniport(IDE RAID) as a solution.
>
> Are there resources available that will help me start writing SCSI
> Miniport driver (for IDE RAID)? I looked at DDK, it has sample code for
> SCSI miniport (for SCSI RAID). Any other resources?
>
> Thanks and Regards,
> Shakeel.
>
>

Hi,

Are there sample source code for SCSI miniport(for IDE) or Documentation
thall will tell what needs to be done to port the SCSI miniport To IDE
scsi miniport.

Wondering how much of work it will be to take the sample SCSI miniport
from DDK to change it into IDE SCSI Miniport (for IDE HBA).

Please advise me from here. I am new to SCSI and SCSI miniport.

Thanks, Shakeel.

> Are there sample source code for SCSI miniport(for IDE) or Documentation

thall will tell what needs to be done to port the SCSI miniport To IDE
scsi miniport.

ATAPI sample from NT4 DDK.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Max,

If I use sample source of NT 4 ATAPI.SYS and make it work on our hardware.
Will this be SCSI miniport(for IDE) what we have discussed. Can the same
driver source code be recompiled on 2000/XP/2003 as 2000/XP/2003 driver?

Thanks, Shakeel.

With minor updates I think. SCSIPORT is nearly the same in NT4 and w2k and
XP, the addition is the AdapterControl routine for power management.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “shakeel”
To: “Windows System Software Devs Interest List”
Sent: Wednesday, October 22, 2003 4:17 AM
Subject: [ntdev] Re: ATA_PASS_THROUGH call from User application

> Max,
>
> If I use sample source of NT 4 ATAPI.SYS and make it work on our hardware.
> Will this be SCSI miniport(for IDE) what we have discussed. Can the same
> driver source code be recompiled on 2000/XP/2003 as 2000/XP/2003 driver?
>
> Thanks, Shakeel.
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com