Re: create an aligned virtual address on already commited memory ?

>1) copy the application data to a properly aligned, temporary buffer. I do

not like this because it consumes time, CPU and memory.

  1. create a new aligned virtual address and, somehow, associate it to the
    provided buffer.
    Can this be done by a Win32 (NT) application ? VirtualAlloc() could be used
    to do half the job, which is to reserve 512KB of virtual memory in the
    process space. Then, we still need to “commit” this VA to the provided
    buffer.

There is no chance you can just take an arbitrary unaligned buffer, and
through page table fun make it aligned. You will HAVE to copy the buffer
under some conditions. The virtual address mapping hardware basically can’t
change the bottom 12 bits of an address.

On the other hand, hardware is getting better about unaligned DMA
transfers, so maybe there actually isn’t the alignment requirement you
think. One of the scsi wizards here could probably tell us the exact
alignment requirements of assorted scsi adapters. Seems like many scsi
adapters were quite happy to do transfers on DWORD alignment, although
cache line alignment was a bit faster. The probability is fairly good a
buffer will be DWORD aligned.

Making a new VA mapping is probably useless to some low level DMA hardware,
which will care about the alignment on a physical memory basis.

  • Jan