Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Home NTDEV

Before Posting...

Please check out the Community Guidelines in the Announcements and Administration Category.

More Info on Driver Writing and Debugging


The free OSR Learning Library has more than 50 articles on a wide variety of topics about writing and debugging device drivers and Minifilters. From introductory level to advanced. All the articles have been recently reviewed and updated, and are written using the clear and definitive style you've come to expect from OSR over the years.


Check out The OSR Learning Library at: https://www.osr.com/osr-learning-library/


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

OSR_Community_UserOSR_Community_User Member Posts: 110,217
>1) copy the application data to a properly aligned, temporary buffer. I do
>not like this because it consumes time, CPU and memory.
>
>2) 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
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started.

Upcoming OSR Seminars
OSR has suspended in-person seminars due to the Covid-19 outbreak. But, don't miss your training! Attend via the internet instead!
Kernel Debugging 13-17 May 2024 Live, Online
Developing Minifilters 1-5 Apr 2024 Live, Online
Internals & Software Drivers 11-15 Mar 2024 Live, Online
Writing WDF Drivers 20-24 May 2024 Live, Online