Physical memory

Hai all,

I have a driver which processes the user data and passes it to the device. But actually for that my driver needs the physical address of the user memory.
Is there any way to get the curresponding physical address of a locked virtual memory in the user mode (may be,without using assembly routines)(the OS is not Win NT, it’s Windows 98). If it’s not possible, can anyone suggest a way to do it in the kernal mode ie in the driver…

thanks in advance

Prasanth


Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi

I think you can pass the address of the user-mode data to the
DeviceIoControl. The address will be automatically translated.

jojan

Jojan T. Antony,
Device Driver Group,
Network Systems and Technologies (P) Ltd.,
A-3 Periyar, Technopark,
Kariyavattom, Thiruvananthapuram
alt.email:xxxxx@eth.net
Ph:91-471-527441

-----Original Message-----
From: prasanth s [mailto:xxxxx@rediffmail.com]
Sent: Thursday, December 28, 2000 11:11 AM
To: NT Developers Interest List
Subject: [ntdev] Physical memory

Hai all,

I have a driver which processes the user data and passes it to the
device. But actually for that my driver needs the physical address of the
user memory.
Is there any way to get the curresponding physical address of a locked
virtual memory in the user mode (may be,without using assembly routines)(the
OS is not Win NT, it’s Windows 98). If it’s not possible, can anyone suggest
a way to do it in the kernal mode ie in the driver…

thanks in advance

Prasanth


Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: xxxxx@nestec.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi,
Thanks for the reply,but that is not need. I have a locked virtual memory region in the user mode. I have to convert that virtual address range in to the curresponding physical address range or ranges. In windows NT I think I can use the KeAttachProcess and parse thro’ the PDE, PTE etc. But I would like to know , if the KeAttachProcess is supported in Win98 or is there any better way to solve this .I feel it’s ok to use assembly code in my program to solve this if no other way is there.

Thanks

prasanth

------------- Original Message --------------
JOJAN wrote:
To:“NT Developers Interest List”
From:JOJAN
Date:Thu, 28 Dec 2000 11:53:21 +0530
Subject:[ntdev] RE: Physical memory

Hi

I think you can pass the address of the user-mode data to the
DeviceIoControl. The address will be automatically translated.

jojan

Jojan T. Antony,
Device Driver Group,
Network Systems and Technologies (P) Ltd.,
A-3 Periyar, Technopark,
Kariyavattom, Thiruvananthapuram
alt.email:xxxxx@eth.net
Ph:91-471-527441

-----Original Message-----
From: prasanth s [mailto:xxxxx@rediffmail.com]
Sent: Thursday, December 28, 2000 11:11 AM
To: NT Developers Interest List
Subject: [ntdev] Physical memory

Hai all,

I have a driver which processes the user data and passes it to the
device. But actually for that my driver needs the physical address of the
user memory.
Is there any way to get the curresponding physical address of a locked
virtual memory in the user mode (may be,without using assembly routines)(the
OS is not Win NT, it’s Windows 98). If it’s not possible, can anyone suggest
a way to do it in the kernal mode ie in the driver…

thanks in advance

Prasanth


Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: xxxxx@nestec.net
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: xxxxx@rediffmail.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Prasanth,

First, the Win32 ‘locked’ virtual memory regions are only locked while your
process has an active thread. From a driver’s perspective this is not a
locked virtual memory buffer at all but is simply pageable data.

Secondly, as the earlier response said, the easiest way for you to do this
is to let the operating system do it for you. The IoManager will be happy to
construct an MDL that describes your user buffer as a set of physical
addresses. If you have a stand-alone driver, then you can use standard
Read/Write IO operations, otherwise you will have to use IOCTL operations.
What you are not going to ever do is use KeAttachProcess or assembly
language operations or parse through the page database.

If you have a stand-alone driver then when you create your device object you
can specify that Read and Write operations will use the IRP.MdlAddress field
to describe the user data buffer. If you do not have a stand-alone driver
then you have to live with whatever your other drivers in your device stack
use for read and write operations. You can however use IOCTL operations,
specifying METHOD_IN_DIRECT or METHOD_OUT_DIRECT to get the IoManager to
describe the IOCTL OutBuffer with IRP.MdlAddress.

Mark Roddy
Windows 2000/NT Consultant
Hollis Technology Solutions
www.hollistech.com

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of prasanth s
Sent: Thursday, December 28, 2000 2:21 AM
To: NT Developers Interest List
Subject: [ntdev] RE: Physical memory

Hi,
Thanks for the reply,but that is not need. I have a locked
virtual memory region in the user mode. I have to convert that
virtual address range in to the curresponding physical address
range or ranges. In windows NT I think I can use the
KeAttachProcess and parse thro’ the PDE, PTE etc. But I would
like to know , if the KeAttachProcess is supported in Win98 or is
there any better way to solve this .I feel it’s ok to use
assembly code in my program to solve this if no other way is there.

Thanks

prasanth

------------- Original Message --------------
JOJAN wrote:
> To:“NT Developers Interest List”
> From:JOJAN
> Date:Thu, 28 Dec 2000 11:53:21 +0530
> Subject:[ntdev] RE: Physical memory
>
> Hi
>
> I think you can pass the address of the user-mode data to the
> DeviceIoControl. The address will be automatically translated.
>
> jojan
>
> Jojan T. Antony,
> Device Driver Group,
> Network Systems and Technologies (P) Ltd.,
> A-3 Periyar, Technopark,
> Kariyavattom, Thiruvananthapuram
> alt.email:xxxxx@eth.net
> Ph:91-471-527441
>
>
> -----Original Message-----
> From: prasanth s [mailto:xxxxx@rediffmail.com]
> Sent: Thursday, December 28, 2000 11:11 AM
> To: NT Developers Interest List
> Subject: [ntdev] Physical memory
>
>
>
>
> Hai all,
>
> I have a driver which processes the user data and passes it to the
> device. But actually for that my driver needs the physical address of the
> user memory.
> Is there any way to get the curresponding physical address of a locked
> virtual memory in the user mode (may be,without using assembly
> routines)(the
> OS is not Win NT, it’s Windows 98). If it’s not possible, can
> anyone suggest
> a way to do it in the kernal mode ie in the driver…
>
> thanks in advance
>
> Prasanth
>
>
> Chat with your friends as soon as they come online. Get Rediff Bol at
> http://bol.rediff.com
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@nestec.net
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> You are currently subscribed to ntdev as: xxxxx@rediffmail.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>

> Chat with your friends as soon as they come online. Get Rediff Bol at
> http://bol.rediff.com
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@wattanuck.mv.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Thanks for the reply,but that is not need. I have a locked virtual
memory >region in the user mode. I have to convert that virtual address
range in to the

curresponding physical address range or ranges. In windows NT I think I can
use the KeAttachProcess and parse thro’ the PDE, PTE etc. But I would like

No.
Lock the pages to the MDL and then deal with the MDL tail - the USHORT array
following struct _MDL.
These will be the physical page numbers - shift them left to 12 to get the
physical addresses.
Do not deal with PTEs directly - this is a bad practice.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hai Max & Mark,

Thanks for the reply.Now I have a serious doubt about this physical memory(even if it’s not related with my problem I am asking ,just to get a clear picture). You told me that the physical address of the user buffer(more precisely page numbers) will be in the locations followed the _MDL in the USHORT form.So even after I am shifting that value by 12 bits to the left the first nibble(MSNibble) will always be zero only. Actually what does it mean ? Whether the operating system can afford only 256MB main memory or if it’s not so, how the OS(?) manages larger amount of physical memory ?

Thanks

prasanth


Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

>page numbers) will be in the locations followed the _MDL in the USHORT

form.So even after I am shifting that value by 12 bits to the left the
first nibble
(MSNibble) will always be zero only. Actually what does it mean ? Whether
the

Surely, this mean that the page start address is always 4KB-aligned -
nothing more.
The page start address is 32 bits (12 lower of them are always zeroes - the
alignment) - thus forming the physical addresses up to 4GB.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

------------- Original Message --------------
“Maxim S. Shatskih” wrote:
To:,
,
“prasanth s”
From:“Maxim S. Shatskih”
Date:Fri, 29 Dec 2000 21:32:57 +0300
Subject:Re: [ntdev] RE: Physical memory

>page numbers) will be in the locations followed the _MDL in the USHORT
>form.So even after I am shifting that value by 12 bits to the left the
first nibble
>(MSNibble) will always be zero only. Actually what does it mean ? Whether
the

Surely, this mean that the page start address is always 4KB-aligned -
nothing more.
The page start address is 32 bits (12 lower of them are always zeroes - the
alignment) - thus forming the physical addresses up to 4GB.

Max

No yaar,
When I am shifting a USHORT 12 bits to the left, the lowest 12 bits will be zeros.That’s ok. But what about the highest 4 bits ?(12 + 16 of USHORT will give only 28 bits, right ?) That bits will also be zeros. If we want to access 4GB memory space the highest 4 bits of the should also be variables. But in our case when we are shifting that USHORT 12 bits to the left we have only 28 bits as variables. My question is whether the OS(?) is doing something to make it possible to access 4GB.

Thanks

eagerly waiting for the reply

prasanth

_____________________________________________________
Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> No yaar,

When I am shifting a USHORT 12 bits to the left, the lowest 12 bits
will be zeros.That’s ok. But what about the highest 4 bits ?(12 + 16 of
USHORT will give only 28 bits, right ?) That bits will also be zeros. If we
want to access 4GB

Wow, sorry for me being wrong.
The MDL tail entries are 32bit words - they are shifted 12 bits left to make
physical addresses. The senior 12 bits of the MDL tail entries are not used
IIRC.
What is 16bit is the size of the MDL (the counter of these entries).

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

------------- Original Message --------------
“Maxim S. Shatskih” wrote:
To:“NT Developers Interest List”
From:“Maxim S. Shatskih”
Date:Tue, 2 Jan 2001 08:25:14 +0300
Subject:[ntdev] Re: Physical memory

Wow, sorry for me being wrong.
The MDL tail entries are 32bit words - they are shifted 12 bits left to make
physical addresses. The senior 12 bits of the MDL tail entries are not used
IIRC.
What is 16bit is the size of the MDL (the counter of these entries).

Max

Hai,
Thanks for spending this much time for me.I am not getting ,what you meant by “What is 16bit is the size of the MDL (the counter of these entries)”. Now my conclusion is that I will get the physical pages from the array of ULONG followed by the MDL and also I can have the number of pages by dividing the (ULONG)ByteCount (member of the struct _MDL) by the page size (4k). If I am wrong please currect me.

Thanks in advance

rgds

prasanth

_____________________________________________________
Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Thanks for spending this much time for me.I am not getting ,what you
meant by “What is 16bit is the size of the MDL (the counter of these
entries)”. Now

typedef struct _MDL {
struct _MDL *Next;
CSHORT Size;

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hai,
Using the PMDL method now I am able to get the physical address.But I have one more doubt. After this “Pages” array in the _MDL somemore values are there when comparing it with the PMDL->Size. Can you just tell me what these values represent ? Is this related to physical memory ?

And also if I want to represent this Physical address using the definition PHYSICAL_ADDRESS How should I use this. Is this PHYSICAL_ADDRESS nowhere related to the physical address or what ? What I am thinking is the LowPart of PHYSICAL_ADDRESS as the physical address HighPart as the process related value.Please currect me if I am wrong.

thanks
prasanth

------------- Original Message --------------
“Maxim S. Shatskih” wrote:
To:“NT Developers Interest List”
From:“Maxim S. Shatskih”
Date:Tue, 2 Jan 2001 14:57:51 +0300
Subject:[ntdev] Re: Physical memory

> Thanks for spending this much time for me.I am not getting ,what you
meant by “What is 16bit is the size of the MDL (the counter of these
entries)”. Now

typedef struct _MDL {
struct _MDL *Next;
CSHORT Size;

Max


You are currently subscribed to ntdev as: xxxxx@rediffmail.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

_____________________________________________________
Chat with your friends as soon as they come online. Get Rediff Bol at
http://bol.rediff.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Prasanth,

The only reason you should need the physical addresses that constitute the
user buffer is because you intend to access this buffer from a peripheral
device, for example a bus master PCI device. While digging through the MDL
will eventually work, the operating system already has a set of APIs that
can be used to do this in a correct, documented, and supported manner.
(Digging through the MDL directly will not work, for example, if you attempt
to access the buffer from a peripheral device on a system that uses Map
Registers.)

I suggest that you take a look at GetScatterGatherList for Windows 2000 or
IoMapTransfer for earlier versions of NT.

Mark Roddy
xxxxx@hollistech.com
www.hollistech.com
WindowsNT Windows 2000 Consulting Services

-----Original Message-----
From: prasanth s [mailto:xxxxx@rediffmail.com]
Sent: Thursday, January 04, 2001 1:41 AM
To: NT Developers Interest List
Subject: [ntdev] Re: Physical memory

Hai,
Using the PMDL method now I am able to get the physical
address.But I have one more doubt. After this “Pages” array
in the _MDL somemore values are there when comparing it with
the PMDL->Size. Can you just tell me what these values
represent ? Is this related to physical memory ?

And also if I want to represent this Physical address using
the definition PHYSICAL_ADDRESS How should I use this. Is
this PHYSICAL_ADDRESS nowhere related to the physical address
or what ? What I am thinking is the LowPart of
PHYSICAL_ADDRESS as the physical address HighPart as the
process related value.Please currect me if I am wrong.

thanks
prasanth

------------- Original Message --------------
“Maxim S. Shatskih” wrote:
> To:“NT Developers Interest List”
> From:“Maxim S. Shatskih”
> Date:Tue, 2 Jan 2001 14:57:51 +0300
> Subject:[ntdev] Re: Physical memory
>
> > Thanks for spending this much time for me.I am not
> getting ,what you
> meant by “What is 16bit is the size of the MDL (the counter of these
> entries)”. Now
>
> typedef struct _MDL {
> struct _MDL *Next;
> CSHORT Size;
>
>
> Max
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@rediffmail.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> _____________________________________________________
> Chat with your friends as soon as they come online. Get Rediff Bol at
> http://bol.rediff.com
>
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

> Using the PMDL method now I am able to get the physical address.But I
have one more doubt. After this “Pages” array in the _MDL somemore values
are there when comparing it with the PMDL->Size. Can you just tell me what
these values represent ? Is this related to physical memory ?

( pMdl->Pages[i] ) << 12 is the physical address.
But! Remember that this is an undocumented thing! It will not work on PAE
machines, for instance - or will work differently.
MS suggests that the only need in a physical address in your code is for
DMA - and suggests to use IoMapTransfer() and GetScatterGatherList() (the
DMA-related functions) instead. They will produce a list of DMAable
addresses which can be fed to your hardware.

nowhere related to the physical address or what ? What I am thinking is the
LowPart of PHYSICAL_ADDRESS as the physical address HighPart as the
process related value.Please currect me if I am wrong.

IIRC this is for PAE support. On PAE, physical addresses can be > 4GB, while
the virtual ones are still < 4GB.

Max


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com