< 32b addressing on a DMA device

This is probably an unusual/odd question but here goes anyway…

I am trying to write a Windows device driver for several PCI devices which includes a “crippled” DMA bus master controller. The DMA controller has 32b address registers, but due to some internal limitation of the FPGA, only a part of this address range is really mapped to the PCI bus. So in effect it has 28b of address on the PCI bus.

It seems that through the use of Map Registers, the Kernel has the potential to handle this situation; as it would for a legacy ISA device. However it appears to me that there is no mechanism to inform the kernel of addressing limitations on the device for less than a full 32b of addresses, other than by designating the device as an ISA device.

Am I missing something, or is this indeed the case? Are there any backdoor methods to trick the kernel into using a lower address range for the map registers of a device when it is not an ISA device? (and if so how?)

Hey! I just looked this up the other day for a dude on this list.

In the DEVICE_DESCRIPTION data structure, you can set Dma64BitAddressess, Dma32BitAddressess, and ScatterGather to FALSE.

Check:

http://www.osronline.com/showthread.cfm?link=184335#T7

Peter
OSR

Check the archives in the last few weeks this same question was answered
for a 31 bit device.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: xxxxx@msn.com [mailto:xxxxx@msn.com]
Posted At: Tuesday, June 29, 2010 4:33 PM
Posted To: ntdev
Conversation: < 32b addressing on a DMA device
Subject: < 32b addressing on a DMA device

This is probably an unusual/odd question but here goes anyway…

I am trying to write a Windows device driver for several PCI devices
which
includes a “crippled” DMA bus master controller. The DMA controller
has 32b
address registers, but due to some internal limitation of the FPGA,
only a
part of this address range is really mapped to the PCI bus. So in
effect it
has 28b of address on the PCI bus.

It seems that through the use of Map Registers, the Kernel has the
potential
to handle this situation; as it would for a legacy ISA device. However
it
appears to me that there is no mechanism to inform the kernel of
addressing
limitations on the device for less than a full 32b of addresses, other
than by
designating the device as an ISA device.

Am I missing something, or is this indeed the case? Are there any
backdoor
methods to trick the kernel into using a lower address range for the
map
registers of a device when it is not an ISA device? (and if so how?)

__________ Information from ESET Smart Security, version of virus
signature
database 5238 (20100629) __________

The message was checked by ESET Smart Security.

http://www.eset.com

Thanks Peter.

I had played with setting SG, 32b and 64b addressing to all false, but I did not see what mechanism exists to inform the kernel of the max address range.

If all these are false, does the kernel just assume ISA style addressing? Or is there another mechanism for setting the address range?

SORT of. You don’t get an infinite number of choices in terms of addressing capacity. The choices are 24-bit, 32-bit, and 64-bit.

Also, note that contrary to common sense, you can NOT set ScatterGather to true (because if you do, as our colleague discovered a week or so back, Windows hammers the Dma32BitAddresses field to TRUE).

Note, selecting 24-bit addressing isn’t exactly equivalent to “ISA style addressing.” The latter implies that DMAs can’t cross 64K boundaries, such as in “Slave Mode” non-BusMaster DMA. I assume you’re device is OK with THAT.

Peter
OSR

Yes, that should work for this device. Luckily it has 28b addressing, so loosing 4b of adress range is not horrible.

Will give that a shot…

Thanks again.

>kernel of addressing limitations on the device for less than a full 32b of addresses, other than by

designating the device as an ISA device.

In year 1999, I saw the PowerPoint document from MS about “PCI hardware design guidelines for Windows”.

It is very, very bad that this document is not widely known to hardware designers. 11 years passed, but these rules are still violated.

For instance, it explicitly says that such addressing limitations are no-no.

Now, with such a broken device, I don’t think you can do anything better except using MmAllocateContiguousMemory with your addressing requirement, double-buffer all incoming data to this buffer, then create MDL off this contiguous buffer and pass it via the usual Windows DMA routines.

Yes, reimplementing the bounce buffer stuff in your own code.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

> In the DEVICE_DESCRIPTION data structure, you can set Dma64BitAddressess,

Dma32BitAddressess, and ScatterGather to FALSE.

Sorry Peter, but there is no such thing as Dma28BitAddresses.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Max,

A lot of that paper went into the hardware guidelines documents that
Microsoft used to put out. It is unfortunate that now all of that data
requires a WHQL login to get at, which means that most firms don’t see
any of it till it is too late.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

-----Original Message-----
From: Maxim S. Shatskih [mailto:xxxxx@storagecraft.com]
Posted At: Thursday, July 01, 2010 8:10 AM
Posted To: ntdev
Conversation: < 32b addressing on a DMA device
Subject: Re: < 32b addressing on a DMA device

>kernel of addressing limitations on the device for less than a full
32b
>of addresses, other than by designating the device as an ISA device.

In year 1999, I saw the PowerPoint document from MS about “PCI
hardware design
guidelines for Windows”.

It is very, very bad that this document is not widely known to
hardware
designers. 11 years passed, but these rules are still violated.

For instance, it explicitly says that such addressing limitations are
no-no.

Now, with such a broken device, I don’t think you can do anything
better
except using MmAllocateContiguousMemory with your addressing
requirement,
double-buffer all incoming data to this buffer, then create MDL off
this
contiguous buffer and pass it via the usual Windows DMA routines.

Yes, reimplementing the bounce buffer stuff in your own code.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

__________ Information from ESET Smart Security, version of virus
signature
database 5242 (20100701) __________

The message was checked by ESET Smart Security.

http://www.eset.com

I don’t follow you. I don’t think I said there WAS such a field.

To repeat:

You set BusMaster=TRUE, ScatterGather=FALSE, and DMA32BitAddresses and DMA64BitAddresses to FALSE.

Ta da! You get a buffer in 28 bit address space. Check out the code…

Peter
OSR