MmGetPhysicalAddress and ZwMapViewOfSection

Hi,

I have a driver which uses MmAllocateContiguousMemory () in DriverEntry()
and then passes the returned virtual address to MmGetPhysicalAddress (). It
stores this physical address for later use. At a later time, can the driver
use this physical address as the “SectionOffset” argument to
ZwMapViewOfSection () to get a virtual address? This virtual address is to
be passed to the user space for use by an application.

I am a little confused by the way it is done in the existing driver and for
reasons into which I will not go into at this time, I have to change
the implementation.

Any help is greatly appreciated.

Thanks in advance,
Sheela.

You could.

-----Original Message-----
From: xxxxx@radisys.com [mailto:xxxxx@radisys.com]
Sent: Sunday, March 05, 2000 6:01 PM
To: NT Developers Interest List
Subject: [ntdev] MmGetPhysicalAddress and ZwMapViewOfSection

Hi,

I have a driver which uses MmAllocateContiguousMemory () in DriverEntry()
and then passes the returned virtual address to MmGetPhysicalAddress (). It
stores this physical address for later use. At a later time, can the driver
use this physical address as the “SectionOffset” argument to
ZwMapViewOfSection () to get a virtual address? This virtual address is to
be passed to the user space for use by an application.

I am a little confused by the way it is done in the existing driver and for
reasons into which I will not go into at this time, I have to change
the implementation.

Any help is greatly appreciated.

Thanks in advance,
Sheela.


You are currently subscribed to ntdev as: xxxxx@microsoft.com
To unsubscribe send a blank email to $subst(‘Email.Unsub’)

Thank you for your reply.

The earlier driver was using HalTranslateBusAddress () on the value
returned from MmGetPhysicalAddress () and this was the value that
was passed to ZwMapViewOfSection (). However, this was on NT 4.0.
The HalTranslateBusAddress () call fails on Win 2K. When I use the
the code without HalTranslateBusAddress () on Win 2k, programming
the device with the physical address and passing the virtual address
returned from ZwMapViewOfSection () to my application (as detailed
in my earlier mail), this memory isn’t seen from another board.
Is there any other way I can achieve this?

Thanks,
Sheela.

On 03/07/00, “Eliyas Yakub ” wrote:
> You could.
>
> -----Original Message-----
> From: xxxxx@radisys.com [mailto:xxxxx@radisys.com]
> Sent: Sunday, March 05, 2000 6:01 PM
> To: NT Developers Interest List
> Subject: [ntdev] MmGetPhysicalAddress and ZwMapViewOfSection
>
>
> Hi,
>
> I have a driver which uses MmAllocateContiguousMemory () in DriverEntry()
> and then passes the returned virtual address to MmGetPhysicalAddress (). It
> stores this physical address for later use. At a later time, can the driver
> use this physical address as the “SectionOffset” argument to
> ZwMapViewOfSection () to get a virtual address? This virtual address is to
> be passed to the user space for use by an application.
>
> I am a little confused by the way it is done in the existing driver and for
> reasons into which I will not go into at this time, I have to change
> the implementation.
>
> Any help is greatly appreciated.
>
> Thanks in advance,
> Sheela.
>
> —
> You are currently subscribed to ntdev as: xxxxx@microsoft.com
> To unsubscribe send a blank email to $subst(‘Email.Unsub’)

> use this physical address as the “SectionOffset” argument to

ZwMapViewOfSection () to get a virtual address? This virtual address is to

No. You need a real section object for ZwMapViewOfSection.
In your case, MmMapLockedPages(…UserMode…) is the right way.

Max

I already have a section object. I used ZwOpenSection () to open
up all of the physical memory as a section.

The other related question is what exactly does MmGetPhysicalAddress ()
return? Does it return a “Bus Address” or a “Physical Address”? And
is there any difference between the return values on NT 4.0 and Windows
2000.

Thanks,
Sheela.

On 03/07/00, ““Maxim S. Shatskih” ” wrote:
> > use this physical address as the “SectionOffset” argument to
> > ZwMapViewOfSection () to get a virtual address? This virtual address is to
>
> No. You need a real section object for ZwMapViewOfSection.
> In your case, MmMapLockedPages(…UserMode…) is the right way.
>
> Max