• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1446
  • Last Modified:

Determining disk transfer mode under XP

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
JamieR
Asked:
JamieR
  • 4
  • 4
  • 2
2 Solutions
 
Jose ParrotGraphics ExpertCommented:
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
 
kjpusCommented:
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
 
Jose ParrotGraphics ExpertCommented:
That's right! Good comment.
Jose
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
JamieRAuthor Commented:
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
 
kjpusCommented:
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
 
JamieRAuthor Commented:
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
 
JamieRAuthor Commented:
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
 
kjpusCommented:
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
 
JamieRAuthor Commented:
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

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now