Hi,
Iam newbie to this device drivers development in windows
environment. can i know, is there any function similar to
virt_to_phy(linux) in windows to convert virtual address to physical
address.
Thanks & Regards
ajay kumar v
Hi,
Iam newbie to this device drivers development in windows
environment. can i know, is there any function similar to
virt_to_phy(linux) in windows to convert virtual address to physical
address.
Thanks & Regards
ajay kumar v
MmGetPhysicalAddress(), and it is easier to use it than Linux memory-mapping functions . It simply returns you the info from the page directory and page table, so that you can use it for kernel addresses, user addresses, RAM, IO Memory - unlike Linux functions, it works exactly the same way for all types of addresses…
Anton Bassov
MmGetPhysicalAddress. However, if you’re doing DMA, you need use the DMA adapter model of operations. (IoGetDmaAdapter)
From: xxxxx@lists.osr.com [xxxxx@lists.osr.com] On Behalf Of ajay kumar [xxxxx@redpinesignals.com]
Sent: Friday, January 09, 2009 1:09 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] Funtion to translate virtual address to physical address
Hi,
Iam newbie to this device drivers development in windows
environment. can i know, is there any function similar to
virt_to_phy(linux) in windows to convert virtual address to physical
address.
Thanks & Regards
ajay kumar v
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
BTW, beware - this function is owned by the Memory Manager, and MM does not maintain a refcount for calls to this function. Therefore, as long as the target virtual address refers to pageable memory it may well happen that the given physical page will be already mapped to some other virtual address(or at least recycled) by the time you try to make any use of it… This problem does not exist under Linux, because Linux provides separate translation functions/macros for different types of addresses, so that it is your responsibility to decide which call to make for a particular type of address…
Anton Bassov
soviet_bloke and skywing thanks for your valuable replies…
Regards
ajay kumar v
xxxxx@hotmail.com wrote:
BTW, beware - this function is owned by the Memory Manager, and MM does not maintain a refcount for calls to this function. Therefore, as long as the target virtual address refers to pageable memory it may well happen that the given physical page will be already mapped to some other virtual address(or at least recycled) by the time you try to make any use of it… This problem does not exist under Linux, because Linux provides separate translation functions/macros for different types of addresses, so that it is your responsibility to decide which call to make for a particular type of address…
Anton Bassov
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminarsTo unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
> environment. can i know, is there any function similar to
virt_to_phy(linux) in windows to convert virtual address to physical
address.
Why do you need a physical address? Windows assumes that the only valid need in this is for DMA, and for DMA, you must use DMA adapter object methods.
Use IoGetDmaAdapter to create an instance of this object.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
MmGetPhysicalAddress will give you the physical address but for you to be
able to read or write to it you will have to open \Device\PhysicalMemory
using ZwCreateFile and use that handle for reading and writing using
ZwReadFile or ZwWriteFile.
Charansing D Deore
Sr. Software Developer,
CalSoft Pvt Ltd.
Baner Road, Pune-411045
Office: +91 20 40792900 Ext: 3052
Cell: +91 9850960550
On Fri, Jan 9, 2009 at 12:19 PM, ajay kumar
wrote:
> soviet_bloke and skywing thanks for your valuable replies…
>
> Regards
> ajay kumar v
>
>
>
> xxxxx@hotmail.com wrote:
>
>> BTW, beware - this function is owned by the Memory Manager, and MM does
>> not maintain a refcount for calls to this function. Therefore, as long as
>> the target virtual address refers to pageable memory it may well happen that
>> the given physical page will be already mapped to some other virtual
>> address(or at least recycled) by the time you try to make any use of it…
>> This problem does not exist under Linux, because Linux provides separate
>> translation functions/macros for different types of addresses, so that it is
>> your responsibility to decide which call to make for a particular type of
>> address…
>>
>> Anton Bassov
>> —
>> 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
>>
>>
>>
>>
>
>
>
> —
> 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
>
> MmGetPhysicalAddress will give you the physical address but for you to be able to read or write
to it you will have to open \Device\PhysicalMemory using ZwCreateFile and use that handle
for reading and writing using ZwReadFile or ZwWriteFile.
Totally ridiculous suggestion - every single piece of the above statement is absolute nonsense…
Anton Bassov
>> to it you will have to open \Device\PhysicalMemory using ZwCreateFile and use that handle
> for reading and writing using ZwReadFile or ZwWriteFile.
Totally ridiculous suggestion - every single piece of the above statement is absolute nonsense…
Using ZwCreateFile on \Device\PhysicalMemory is especially smiling
IIRC \Device\PhysicalMemory is deprecated since Server 2003. Before it, it was used internally by VideoPrt.sys to map the video memory to some addresses on a request from the video miniport (in turn asked by video DLL, in turn asked by DirectDraw/3D).
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
Hi,
I saw some piece of code(working fine) referring to the \device\physicalmemory in an application which is till date supported on XP only. This user mode App. open and map this section to read data from this; I checked that this is working fine on a XP machine.
later on while searching for some information related to \device\physicalmemory, I reached this thread.
Anton/Max: Apart from this being declared deprecated from 2K3 SP1 and the use of ZwCreateFile on the section, Is there something else which can cause some harm?
Kindly suggest?
Thanks
Aditya