View Single Post
  #3  
Old March 13th 12, 06:22 AM posted to alt.windows7.general
rsyed
external usenet poster
 
Posts: 2
Default How to allocate physically contiguous memory in user mode on windows 7

Paul wrote on 03/12/2012 13:39 ET :
rsyed wrote:
Hello,

I want to allocate non paged physically contiguous memory in system memory in
"user mode". Can any one suggest me the API through which we can
achieve this, or the way we can achieve this.

FYI,
I know that we can achieve this in kernel mode using the API
"MmAllocateContiguousMemory".

Regards,
Rahim.



In user space (ring 3), there is no such requirement. User space
uses virtual addresses, and the physical memory referenced by
a virtual address, doesn't have to be contiguous. Only a driver
writer would care to make the PA addresses contiguous (and only
for the benefit of some dumb DMA circuits). Ordinary program
writers, are "insulated" from hardware, and only care that the
virtual addresses are contiguous. In this example, my program
gets what looks like four contiguous storage locations, even though
there in two different areas of physical memory.

CPU -- VA TLB PA
0x01 0x23
0x02 0x24
0x03 0x58
0x04 0x59

You don't write drivers in user space. You write them in
kernel space (ring 0) and in there, the MmAllocateContiguousMemory
can help you define contiguous addresses, for hardware which
lacks scatter/gather DMA support. Perhaps something like
the AGP GART, would have been an example of an area needing
something like MmAllocateContiguousMemory.

PA DMA hardware, PCI bus
0x23 (for architectures where the peripherals
0x24 chips don't have access to a mapper or TLB.)
0x25
0x26 A few processors now, have an IOMMU, to add
the ability to do translations here. But
since not all processors have an IOMMU, it's
not a feature the OS can rely on. Having an
IOMMU, avoids the need for bounce buffers.

HTH,
Paul

“We have a requirement to allocate a pinned memory(non swappable
physical
page memory) in user mode of windows 7, can someone suggest how this can be
achieved in user mode, which are the windows API’s available ”.
Little explanation and Links to the documents would be helpful.

Regards,
Rahim.
Ads