Solved

Determining disk transfer mode under XP

Posted on 2006-06-30
11
1,432 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

622 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