oppsite of MmMapIoSpace

Hi there a function in windows that lets you get the physical address for a
logical address?

thanks

ap

A P wrote:

Hi there a function in windows that lets you get the physical address
for a logical address?

Surprise… MmGetPhysicalAddress()

–pa

“The opposite of MmMapIoSpace()” is MmUnmapIoSpace(), and “a function in windows that lets you get the physical address for a logical address” is MmGetPhysicalAddress(). …

Anton Bassov

Please note that (for the OP’s benefit), one must use the proper DMA interface if they are going to use this for anything DMA related.

  • S

-----Original Message-----
From: Pavel A.
Sent: Thursday, July 16, 2009 07:08
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] oppsite of MmMapIoSpace

A P wrote:
> Hi there a function in windows that lets you get the physical address
> for a logical address?

Surprise… MmGetPhysicalAddress()

–pa


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Why do you need this?

Usually, it is assumed that physical addresses are needed for DMA only, and you must use DMA APIs for this purpose.


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

“A P” wrote in message news:xxxxx@ntdev…
Hi there a function in windows that lets you get the physical address for a logical address?

thanks

ap

>

Why do you need this?

Usually, it is assumed that physical addresses are needed for DMA
only,
and you must use DMA APIs for this purpose.

One exception to this is in a virtualised environment when you want to
tell the hypervisor to do ‘DMA’ from your memory. In this case, the
‘device’ you are using probably isn’t on the PCI bus so the DMA
functions don’t work (well actually I think they do under 32 bit but
they certainly don’t under 64 bit, but the DMA isn’t PCI bus master DMA
so using the PCI DMA functions is the wrong thing to do). So you have to
get the physical address, extract the PFN and offset from it (or get the
MDL and use the PFN array) and pass that information to the hypervisor.

In my case I wrote a DMA_ADAPTER that does all the right things on my
bus, but that doesn’t appear to be supported by Microsoft - I had to
fudge things a bit to make crash dumps work (crash dump code uses
internal DMA_ADAPTER members) and the verifier causes a BSoD (again,
because the verifier uses undocumented calls), so I wouldn’t advise this
approach. It sure is fast though.

James