Solved

Determining disk transfer mode under XP

Posted on 2006-06-30
11
1,427 Views
Last Modified: 2010-05-18
How do I programatically determine the following properties for any fixed disks that are installed in a Windows XP machine:

1) The supportted transfer modes (PIO, UDMA).
2) The current transfer mode being used.

Looking for example source code in C, or at least a pointer in the right direction.

Thanks,
J
0
Comment
Question by:JamieR
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
11 Comments
 
LVL 18

Assisted Solution

by:Jose Parrot
Jose Parrot earned 100 total points
ID: 17020949
Hi,

This is done at register level. Not a simple API call. Changes will be effective after reboot.

At HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}
in 0000 Make a new DWord named "DMA fix” and give it the value: 1
in 0001 Make a new DWord named: "DmaDetectionLevel” , value = 2
in 0002 Make a new DWord named "DmaDetectionLevel", value = 2

So, the program should set these values in the register, as usual. By changing this, you force xp to DMA, given it no chance to switch to PIO.

For deeper information on DMA settings, take a look at Microsoft's
DMA Mode for ATA/ATAPI Devices in Windows XP:
http://www.microsoft.com/whdc/device/storage/ide-dma.mspx
http://www.microsoft.com/whdc/hwdev/tech/storage/ide-dma.mspx

Hope it helps!

Jose
0
 
LVL 2

Expert Comment

by:kjpus
ID: 17022286
It seems Jose's method will tell the OS to check DMA status but will not tell you what mode the controller is using. You need a few more registry keys to do this:

HKLM\System\CCS\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}

0000 - IDE controller itself - reg_dword "EnableUDMA66", value 1.
0001 - primary channel,
0002 - secondary channel.

Both channels, dwords:
MasterDeviceTimingModeAllowed 0xFFFFFFFF
SlaveDeviceTimingModeAllowed 0xFFFFFFFF
UserMasterDeviceTimingModeAllowed 0xFFFFFFFF
UserSlaveDeviceTimingModeAllowed 0xFFFFFFFF
and
MasterDeviceTimingMode 0xFFFF or 0xFFFFF
SlaveDeviceTimingMode 0xFFFF or 0xFFFFF
or
for Multi-Word DMA Mode 2 and PIO4 (burners, very old HDDs...) - 0x0410
for Ultra ATA33 (CDROMs, DVDs, old HDDs...) - 0x2010
for Ultra ATA66 (just HDDs) - 0x8010
for Ultra ATA100 (modern HDDs) - 0x10010
for Ultra ATA133 (ultramodern HDDs) - 0x12010
0
 
LVL 18

Expert Comment

by:Jose Parrot
ID: 17022419
That's right! Good comment.
Jose
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 1

Author Comment

by:JamieR
ID: 17036429
Thanks for your comments. However, it seems that this method forces XP to use DMA. I really need some way to determine the current mode without changing it - this functionality for a diagnosis application. :(
0
 
LVL 2

Expert Comment

by:kjpus
ID: 17036769
Well, you just need to read the value in MasterDeviceTimingMode or SlaveDeviceTimingMode and determine whether it's PIO or DMA, and what which mode it is. It's easier than changing the mode programmatically.

0
 
LVL 1

Author Comment

by:JamieR
ID: 17042699
Yes, this looks good. Is there a definitive list of the values for MasterDeviceTimingMode / SlaveDeviceTimingMode somewhere?

It appears that different bits represent different modes, but all the examples I have seen have two bits set. For instance,

MasterDeviceTimingMode = 0x10010 (10000000000010000). This implies UDMA Mode 5 (ATA100). It seems bit 16 represents UDMA mode 5, but why is bit 4 also set? Microsoft don't seem to publish this information.

Thanks.
0
 
LVL 1

Author Comment

by:JamieR
ID: 17058750
Thanks for your help. I've sucessfully been able to decode the bitmask and determine the transfer mode for each entry.

However, I have one last problem. I'm having trouble correlating this information with the actual drives installed in the machine. For example, one machine I have tested has the following informaton under HKLM\DEVICEMAP\Scsi\...

Port 0, Bus 0, TID 0, LID 0
                Type: DiskPeripheral
      Identifier: WDC WD200EB-00CPF0
      Driver: atapi
      DMAEnabled: 1

Port 1, Bus 0, TID 1, LID 0
                Type: CdRomPeripheral
      Identifier: HL-DT-ST CD-ROM GCR-8520B
      Driver: atapi
      DMAEnabled: 0

This implies the machine only has one HD and one CD-ROM.

Now, on the same machine, here's the information under HKLM\System\CCS\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318}

[0000]      DriverDesc: VIA Bus Master IDE Controller
      Driver Version: 5.1.3597.0
      Driver Date: 7-1-2001
      Driver Provider: Microsoft

[0001]      DriverDesc: Secondary IDE Channel
      Driver Version: 5.1.2600.1106
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: (unknown) (0x0)
      Slave Transfer Mode: PIO Mode 4 (0x10)

[0002]      DriverDesc: Primary IDE Channel
      Driver Version: 5.1.2600.1106
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: UDMA Mode 5 (ATA100) (0x10010)
      Slave Transfer Mode: (unknown) (0x0)

[0003]      DriverDesc: VIA Bus Master IDE Controller
      Driver Version: 5.1.2600.2180
      Driver Date: 7-1-2001
      Driver Provider: Microsoft

[0004]      DriverDesc: Primary IDE Channel
      Driver Version: 5.1.2600.2180
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: UDMA Mode 4 (ATA66) (0x8010)
      Slave Transfer Mode: (unknown) (0x0)

[0005]      DriverDesc: Secondary IDE Channel
      Driver Version: 5.1.2600.2180
      Driver Date: 7-1-2001
      Driver Provider: Microsoft
      Master Transfer Mode: (unknown) (0x0)
      Slave Transfer Mode: PIO Mode 4 (0x10)

Unfortunately this PC is remotely located, so I can't determine the actual hardware configuration.

1) Why are there more entries for transfer modes than there are hardware devices?
2) How do I work out which devices are installed on which port (primary / secondary and master / slave)?
3) How do I increase the points awarded for this question so I can reward you for all your hard work?! :)

Thanks.

J
0
 
LVL 2

Accepted Solution

by:
kjpus earned 400 total points
ID: 17061967
I don't know why you have two sets of controllers with different transfer mode. Might be some other devices or vitual drive?

There must be an easier way to get the disk drive / IDE channel mapping. But I only know how to get that using WMI. First, query WIN32_CDROMDRIVE AND WIN32_DISKDRIVE to get all drives on the system. You may need to filter out things like USB disk. Then query WIN32_IDEControllerDevice and look into the dependant field. That will give you wheather the disk is on primary or secondary IDE channel. Slave/Master can be determined by SCSILogicalUnit of the first query.

I'm glad I can help.

0
 
LVL 1

Author Comment

by:JamieR
ID: 17231187
I ended up using a combination of things - the registry, WMI (SELECT * FROM CIM_MediaAccessDevice) and various DeviceIoControl calls (IOCTL_SCSI_GET_ADDRESS, SMART_SEND_DRIVE_COMMAND and DFP_GET_VERSION).

Thanks to everyone for their assistance.

Jamie
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
A short article about problems I had with the new location API and permissions in Marshmallow
Simple Linear Regression
Starting up a Project

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question