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

Determing which channel an IDE device is on...

5 views
Skip to first unread message

Agendum

unread,
Nov 24, 2002, 12:52:40 AM11/24/02
to
First, is it possible that a computer have multiple IDE controllers? If so,
how many is possible?

Now I am having trouble determining which channel a device is on. I think I
have established determining if a device is the master or slave by using the
SetupDi* functions to query the LocationInformation (or maybe UINumber?)
registry property. I am not exactly 100% sure if this number means
0=master, 1=slave, but it seems consistent with the devices I have
installed. But my IDE controller has two channels.. the Primary and
Secondary channel, each has a master and slave. How could I determine which
channel a device is on?

Finally, if a machine can have multiple IDE controllers, how could I detect
which controller it is on? Again I am easily capable of getting a
collection of the IDE controllers (if multiple can exist) using SetupDi*
functions, its just linking these to the disk devices is what I am having
trouble with.

Thanks


Maxim S. Shatskih

unread,
Nov 24, 2002, 7:44:09 AM11/24/02
to
> First, is it possible that a computer have multiple IDE controllers?
If so,
> how many is possible?

You can populate all your PCI slots with Promise cards. :-)

> Finally, if a machine can have multiple IDE controllers, how could I
detect
> which controller it is on?

Enumerate all IDE controllers by SetupDiGetClassDevs, then enumerate
their disk children.

Max

Agendum

unread,
Nov 24, 2002, 1:40:21 PM11/24/02
to
Thanks for the info.

Enumerating IDE controllers within \PCI\, I was able to find a consistent
link with the ParentIdPrefix value. It is linked to:

SYSTEM\CurrentControlSet\Enum\PCIIDE\IDEChannel\%A&%B

where %A = ParentIdPrefix value and %B is 0 for primary channel, and 1 for
secondary channel. This is great...

Yet I am only partially on my way to establishing a hard link from the
SetupDi* functions to my manual data structures (I also manually open drives
with CreateFile() to do some IOCTLs). I can easily discover names such as
these:

\\.\PHYSICALDRIVE0
\\.\Harddisk0
\Device\Harddisk0\DR0
and even a volume: \Device\HarddiskVolume0

And I have the SCSI location (for example, the hard drive above is actually
at Port 0, Bus 0, Target Id 0, LUN 0.

On the SetupAPI side, there is a function SetupDiGetDeviceRegistryProperty()
which allows to retrieve the property known as
SPDRP_PHYSICAL_DEVICE_OBJECT_NAME. For the specific harddisk above, it
returns:

\Device\Ide\IdeDeviceP0T0L0-e

Is it safe to assume this means Port 0, Target Id 0, LUN 0? I have no idea
what the "-e" would mean... and why did they leave out the bus if this label
really maps the SCSI port? I read somewhere that Microsoft mapped ATA
devices to SCSI Port 0, is this true? I actually have a machine here in my
office that has an ATA DVD on Port 1, Bus 0, Target Id 0, LUN 0 (so I guess
its not true... I have verified the PDO for it is
\Device\Ide\IdeDeviceP1T0L0-e). I personally haven't seen an ATA device on
a Bus other than zero, but this is just on a handful of computers I have
been testing on.

The PDO for the two IDE Channels are:

\Device\Ide\PciIde0Channel0-0 (Primary)
\Device\Ide\PciIde0Channel1-1 (Secondary)

Anyway, if somebody out there could help me to figure out what channel a
given ATA device is on, I would appreciate it.

Thanks


"Maxim S. Shatskih" <ma...@storagecraft.com> wrote in message
news:#nSdzg7kCHA.1688@tkmsftngp08...

Agendum

unread,
Nov 25, 2002, 7:37:12 AM11/25/02
to
I just had a revelation which I could not find any documentation to back
up... so was hoping somebody here could tell me. For the way ATA devices
are mapped to SCSI, is the following true:

* Each IDE channel is mapped as a SCSI Port.

If this is true, it would sure help in determining where a device lives...
it also makes me question what the key names represent for IDE channels:

Enum\PCIIDE\IDEChannel\4&33180d82&0&0 (Primary Channel)
Enum\PCIIDE\IDEChannel\4&33180d82&0&1 (Secondary Channel)

What does the last number _really_ represent... is it the SCSI Port? I ask
because what if I have 2 IDE Controllers? Could somebody who has 2 IDE
controllers please tell me what the last numbers are?

Enum\PCIIDE\IDEChannel\4&33180d82&0&0 (Primary Channel)
Enum\PCIIDE\IDEChannel\4&33180d82&0&1 (Secondary Channel)
Enum\PCIIDE\IDEChannel\4&51456732&?&3 (Primary Channel) [or will it be 0?]
Enum\PCIIDE\IDEChannel\4&51456732&?&4 (Secondary Channel) [or will it be 1?]

And for 2 controllers, I am curious to know if the second to last number
changes per the IDE controller number?

Finally, where can I get documentation on how to interpret these registry
keys. Also I would like documentation on how to read the "Physical Device
Object Name"...

Thanks


"Agendum" <inv...@address.com> wrote in message
news:OmeS3j#kCHA.972@tkmsftngp12...

Jim Cavalaris [MS]

unread,
Nov 25, 2002, 2:29:00 PM11/25/02
to
maxim's suggestion was to use SetupDiGetClassDevs and SetupDiEnumDeviceInfo
to enumerate devices in the system, not to enumerate the Enum keys directly.

SetupDiGetClassDevs:
http://msdn.microsoft.com/library/en-us/install/hh/install/di-rtns_9ks2.asp

SetupDiEnumDeviceInfo:
http://msdn.microsoft.com/library/en-us/install/hh/install/di-rtns_8z5e.asp

do NOT enumerate keys under the Enum branch of the registry directly, since they
may not give you an accurate representation the hardware that is currently in the
system at the time.

also, do not open these keys directly. the data contained in these keys is internal
to plug and play, and the format is subject to change. specifically -- do not rely
on the ParentIdPrefix values, or the format of the instance key. nearly all the
values in these keys are retrievable using supported means, you should not
have to manipulate this data directly.

you can retrieve information about device properties using
SetupDiGetDeviceRegistryProperty, or by querying any device-specific
information that is stored in one of the keys that can be retrieved using
SetupDiOpenDevRegKey.

specifically, if you need to know if the device is a primary/secondary
IDE channel, take a look at the SPDRP_LOCATION_INFORMATION
property ("Primary Channel" or "Secondary Channel"):

SPDRP_LOCATION_INFORMATION
http://msdn.microsoft.com/library/en-us/install/hh/install/di-rtns_4x2q.asp
The function retrieves the device's LocationInformation registry value,
which is a string describing the device's hardware location.

if you need to retrieve relationships between devices, use the following
Configuration Manager APIs:

CM_Get_Parent_Ex:
http://msdn.microsoft.com/library/en-us/install/hh/install/cfgmgrfn_67ea.asp

CM_Get_Sibling_Ex:
http://msdn.microsoft.com/library/en-us/install/hh/install/cfgmgrfn_0lte.asp

CM_Get_Child_Ex:
http://msdn.microsoft.com/library/en-us/install/hh/install/cfgmgrfn_9zw2.asp

using the DevInst field from an enumerated device's SP_DEVINFO_DATA
that you enumerated from a device info list with SetupDiEnumDeviceInfo.

SP_DEVINFO_DATA:
http://msdn.microsoft.com/library/en-us/install/hh/install/di-struct_7nqq.asp

if connected to the local machine (used SetupDiGetClassDevs, or NULL
for the machine name with SetupDiGetClassDevsEx), you can use the
non-Ex versions CM_Get_Parent, CM_Get_Sibling, and CM_Get_Child.

if connected to a remote machine, use SetupDiGetDeviceInfoListDetail
to retrieve the the RemoteMachineHandle correspoding to your HDEVINFO:

SetupDiGetDeviceInfoListDetail:
http://msdn.microsoft.com/library/en-us/install/hh/install/di-rtns_8j5e.asp

SP_DEVINFO_LIST_DETAIL_DATA:
http://msdn.microsoft.com/library/en-us/install/hh/install/di-struct_2rci.asp

hope this helps,
jim.

"Agendum" <inv...@address.com> wrote in message news:#y10g9HlCHA.2088@tkmsftngp10...

0 new messages