1
votes

We are writing a DMA-based driver for a custom made PCI-Express device using WDF for Windows 7.

As you may know, PCI-Express bus transactions are not allowed to cross a 4k memory boundary. The custom device does not check this, and therefore we need to ensure that the driver only requests DMA transfers which are aligned to 4k memory boundaries.

The profile for the device is WdfDmaProfilePacket64.

We tried using WdfDeviceSetAlignmentRequirement(DevExt->Device, 4095), but this does not result in the DMA start address to be properly aligned.

How can we configure the WDF framework so that it only requests properly aligned addresses?

1

1 Answers

0
votes

you can handle this in user space application, somehow that you initiate/allocate an aligned memory in user space and then send it to kernel program. it is not easy for a driver to align a memory which already allocated and initiated. even in user-space application we have to allocating extra space and then using the aligned part(I know, it's not pretty, that's why i recommend to solve this problem in device side)

for example if you use C++ for your user-space application you can do something like this