MmMapLockedPagesSpecifyCache

Hello

I’m trying to implement common buffer DMA.
Driver calls AllocateCommonBuffer to get the contiguous memory ( 2MBytes or
more ) and build the MDL:

//…
ext->dma.cb_vaddr = (ULONG)
ext->dma.AdapterObject->DmaOperations->AllocateCommonBuffer(ext->dma.Adapter
Object, ext->Camera.Size, &ext->dma.phaddr, FALSE);
//…
PMDL pmdl = IoAllocateMdl((PVOID)ext->dma.cb_vaddr, ext->Size, FALSE, FALSE,
NULL);
if(pmdl == NULL)
{
//…
return FALSE;
}
ext->dma.cb_mdl = pmdl;
MmBuildMdlForNonPagedPool(pmdl);
//…

Than aplication allocates the 2MBytes of the virtual memory and gives to the
driver this buffer, using METHOD_NEITHER method
Driver tryes to map it to the common buffer (ext->dma.cb_vaddr), but gets
the BSOD after calling

ext->dma.user_vaddr = (ULONG)buff_out;
ULONG user_addr = (ULONG)MmMapLockedPagesSpecifyCache( ext->dma.cb_mdl,
UserMode, MmNonCached, (PVOID)ext->dma.user_vaddr, FALSE,
NormalPagePriority );

Of course, if ext->dma.user_vaddr == NULL, MmMapLockedPagesSpecifyCache
works fine, but I need to map the address, specified by the application! Are
there the ways to implement it?
Are there the way to map fixed User mode address to the contiguous pages?
Please, do not suggest me to read the article from NT Insider 7.2. Article
is great, but I need to map fixed address, specified by the application.

Thanks a lot,
Nikolay

Why are you attempting to build an MDL for the common buffer?
AllocateCommonBuffer returns both the physical address of the start of the
buffer and the virtual address to use in your code to access it - what
more do you need?

/simgr

-----Original Message-----
From: Nikolay [mailto:xxxxx@pisem.net]
Sent: Monday, September 15, 2003 1:31 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] MmMapLockedPagesSpecifyCache

Hello

I’m trying to implement common buffer DMA.
Driver calls AllocateCommonBuffer to get the contiguous memory ( 2MBytes or
more ) and build the MDL:

//…
ext->dma.cb_vaddr = (ULONG)
ext->dma.AdapterObject->DmaOperations->AllocateCommonBuffer(ext->dma.Adapter
Object, ext->Camera.Size, &ext->dma.phaddr, FALSE);
//…
PMDL pmdl = IoAllocateMdl((PVOID)ext->dma.cb_vaddr, ext->Size, FALSE, FALSE,
NULL);
if(pmdl == NULL)
{
//…
return FALSE;
}
ext->dma.cb_mdl = pmdl;
MmBuildMdlForNonPagedPool(pmdl);
//…

Than aplication allocates the 2MBytes of the virtual memory and gives to the
driver this buffer, using METHOD_NEITHER method
Driver tryes to map it to the common buffer (ext->dma.cb_vaddr), but gets
the BSOD after calling

ext->dma.user_vaddr = (ULONG)buff_out;
ULONG user_addr = (ULONG)MmMapLockedPagesSpecifyCache( ext->dma.cb_mdl,
UserMode, MmNonCached, (PVOID)ext->dma.user_vaddr, FALSE,
NormalPagePriority );

Of course, if ext->dma.user_vaddr == NULL, MmMapLockedPagesSpecifyCache
works fine, but I need to map the address, specified by the application! Are
there the ways to implement it?
Are there the way to map fixed User mode address to the contiguous pages?
Please, do not suggest me to read the article from NT Insider 7.2. Article
is great, but I need to map fixed address, specified by the application.

Thanks a lot,
Nikolay


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

I need to map the common buffer to the user mode memory and perform DMA to
this memory.

“Graham, Simon” wrote in message
news:xxxxx@ntdev…
>
> Why are you attempting to build an MDL for the common buffer?
> AllocateCommonBuffer returns both the physical address of the start of the
> buffer and the virtual address to use in your code to access it - what
> more do you need?
>
> /simgr
>
> -----Original Message-----
> From: Nikolay [mailto:xxxxx@pisem.net]
> Sent: Monday, September 15, 2003 1:31 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] MmMapLockedPagesSpecifyCache
>
> Hello
>
> I’m trying to implement common buffer DMA.
> Driver calls AllocateCommonBuffer to get the contiguous memory ( 2MBytes
or
> more ) and build the MDL:
>
> //…
> ext->dma.cb_vaddr = (ULONG)
>
ext->dma.AdapterObject->DmaOperations->AllocateCommonBuffer(ext->dma.Adapter
> Object, ext->Camera.Size, &ext->dma.phaddr, FALSE);
> //…
> PMDL pmdl = IoAllocateMdl((PVOID)ext->dma.cb_vaddr, ext->Size, FALSE,
FALSE,
> NULL);
> if(pmdl == NULL)
> {
> //…
> return FALSE;
> }
> ext->dma.cb_mdl = pmdl;
> MmBuildMdlForNonPagedPool(pmdl);
> //…
>
> Than aplication allocates the 2MBytes of the virtual memory and gives to
the
> driver this buffer, using METHOD_NEITHER method
> Driver tryes to map it to the common buffer (ext->dma.cb_vaddr), but gets
> the BSOD after calling
>
> ext->dma.user_vaddr = (ULONG)buff_out;
> ULONG user_addr = (ULONG)MmMapLockedPagesSpecifyCache( ext->dma.cb_mdl,
> UserMode, MmNonCached, (PVOID)ext->dma.user_vaddr, FALSE,
> NormalPagePriority );
>
> Of course, if ext->dma.user_vaddr == NULL, MmMapLockedPagesSpecifyCache
> works fine, but I need to map the address, specified by the application!
Are
> there the ways to implement it?
> Are there the way to map fixed User mode address to the contiguous pages?
> Please, do not suggest me to read the article from NT Insider 7.2. Article
> is great, but I need to map fixed address, specified by the application.
>
> Thanks a lot,
> Nikolay
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>

What BSOD ?

----- Original Message -----
From: “Nikolay”
Newsgroups: ntdev
To: “Windows System Software Devs Interest List”
Sent: Monday, September 15, 2003 8:58 PM
Subject: [ntdev] Re: MmMapLockedPagesSpecifyCache

> I need to map the common buffer to the user mode memory and perform DMA to
> this memory.
>
> “Graham, Simon” wrote in message
> news:xxxxx@ntdev…
> >
> > Why are you attempting to build an MDL for the common buffer?
> > AllocateCommonBuffer returns both the physical address of the start of
the
> > buffer and the virtual address to use in your code to access it - what
> > more do you need?
> >
> > /simgr
> >
> > -----Original Message-----
> > From: Nikolay [mailto:xxxxx@pisem.net]
> > Sent: Monday, September 15, 2003 1:31 PM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] MmMapLockedPagesSpecifyCache
> >
> > Hello
> >
> > I’m trying to implement common buffer DMA.
> > Driver calls AllocateCommonBuffer to get the contiguous memory ( 2MBytes
> or
> > more ) and build the MDL:
> >
> > //…
> > ext->dma.cb_vaddr = (ULONG)
> >
>
ext->dma.AdapterObject->DmaOperations->AllocateCommonBuffer(ext->dma.Adapter
> > Object, ext->Camera.Size, &ext->dma.phaddr, FALSE);
> > //…
> > PMDL pmdl = IoAllocateMdl((PVOID)ext->dma.cb_vaddr, ext->Size, FALSE,
> FALSE,
> > NULL);
> > if(pmdl == NULL)
> > {
> > //…
> > return FALSE;
> > }
> > ext->dma.cb_mdl = pmdl;
> > MmBuildMdlForNonPagedPool(pmdl);
> > //…
> >
> > Than aplication allocates the 2MBytes of the virtual memory and gives to
> the
> > driver this buffer, using METHOD_NEITHER method
> > Driver tryes to map it to the common buffer (ext->dma.cb_vaddr), but
gets
> > the BSOD after calling
> >
> > ext->dma.user_vaddr = (ULONG)buff_out;
> > ULONG user_addr = (ULONG)MmMapLockedPagesSpecifyCache( ext->dma.cb_mdl,
> > UserMode, MmNonCached, (PVOID)ext->dma.user_vaddr, FALSE,
> > NormalPagePriority );
> >
> > Of course, if ext->dma.user_vaddr == NULL, MmMapLockedPagesSpecifyCache
> > works fine, but I need to map the address, specified by the application!
> Are
> > there the ways to implement it?
> > Are there the way to map fixed User mode address to the contiguous
pages?
> > Please, do not suggest me to read the article from NT Insider 7.2.
Article
> > is great, but I need to map fixed address, specified by the application.
> >
> > Thanks a lot,
> > Nikolay
> >
> >
> >
> >
> > —
> > Questions? First check the Kernel Driver FAQ at
> > http://www.osronline.com/article.cfm?id=256
> >
> > You are currently subscribed to ntdev as: xxxxx@stratus.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@rdsor.ro
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Oh OK, sorry I misunderstood – I think it would be helpful then if you
could give more detail on the BSOD you see - that should help pinpoint the
problem…

/simgr

-----Original Message-----
From: Nikolay [mailto:xxxxx@pisem.net]
Sent: Monday, September 15, 2003 1:59 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] Re: MmMapLockedPagesSpecifyCache

I need to map the common buffer to the user mode memory and perform DMA to
this memory.

“Graham, Simon” wrote in message
news:xxxxx@ntdev…
>
> Why are you attempting to build an MDL for the common buffer?
> AllocateCommonBuffer returns both the physical address of the start of the
> buffer and the virtual address to use in your code to access it - what
> more do you need?
>
> /simgr
>
> -----Original Message-----
> From: Nikolay [mailto:xxxxx@pisem.net]
> Sent: Monday, September 15, 2003 1:31 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] MmMapLockedPagesSpecifyCache
>
> Hello
>
> I’m trying to implement common buffer DMA.
> Driver calls AllocateCommonBuffer to get the contiguous memory ( 2MBytes
or
> more ) and build the MDL:
>
> //…
> ext->dma.cb_vaddr = (ULONG)
>
ext->dma.AdapterObject->DmaOperations->AllocateCommonBuffer(ext->dma.Adapter
> Object, ext->Camera.Size, &ext->dma.phaddr, FALSE);
> //…
> PMDL pmdl = IoAllocateMdl((PVOID)ext->dma.cb_vaddr, ext->Size, FALSE,
FALSE,
> NULL);
> if(pmdl == NULL)
> {
> //…
> return FALSE;
> }
> ext->dma.cb_mdl = pmdl;
> MmBuildMdlForNonPagedPool(pmdl);
> //…
>
> Than aplication allocates the 2MBytes of the virtual memory and gives to
the
> driver this buffer, using METHOD_NEITHER method
> Driver tryes to map it to the common buffer (ext->dma.cb_vaddr), but gets
> the BSOD after calling
>
> ext->dma.user_vaddr = (ULONG)buff_out;
> ULONG user_addr = (ULONG)MmMapLockedPagesSpecifyCache( ext->dma.cb_mdl,
> UserMode, MmNonCached, (PVOID)ext->dma.user_vaddr, FALSE,
> NormalPagePriority );
>
> Of course, if ext->dma.user_vaddr == NULL, MmMapLockedPagesSpecifyCache
> works fine, but I need to map the address, specified by the application!
Are
> there the ways to implement it?
> Are there the way to map fixed User mode address to the contiguous pages?
> Please, do not suggest me to read the article from NT Insider 7.2. Article
> is great, but I need to map fixed address, specified by the application.
>
> Thanks a lot,
> Nikolay
>
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@stratus.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@stratus.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

> Are there the way to map fixed User mode address to the contiguous pages?

Please, do not suggest me to read the article from NT Insider 7.2. Article
is great, but I need to map fixed address, specified by the application.

You cannot. You only can map the common buffer to some user address, and
return this address for the app in IOCTL output buffer. Any address specified
to MmMapLockedPagesSpecifyCache is a hint, the OS can ignore it.

If you’re speaking about “map fixed User mode address to the contiguous
pages” - then this means that you do not understand NT’s VM system at all.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

> I need to map the common buffer to the user mode memory and perform DMA to

this memory.

Then sorry, the user address will be chosen not by you, but by the OS. You must
return it to the app in IOCTL output buffer.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Thanx a lot…
Probably I do not understand NT’s VM system at all…
…but I have done it and it works Ok on my side :-))

“Maxim S. Shatskih” wrote in message
news:xxxxx@ntdev…
>
> > Are there the way to map fixed User mode address to the contiguous
pages?
> > Please, do not suggest me to read the article from NT Insider 7.2.
Article
> > is great, but I need to map fixed address, specified by the application.
>
> You cannot. You only can map the common buffer to some user address, and
> return this address for the app in IOCTL output buffer. Any address
specified
> to MmMapLockedPagesSpecifyCache is a hint, the OS can ignore it.
>
> If you’re speaking about “map fixed User mode address to the contiguous
> pages” - then this means that you do not understand NT’s VM system at all.
>
> Maxim Shatskih, Windows DDK MVP
> StorageCraft Corporation
> xxxxx@storagecraft.com
> http://www.storagecraft.com
>
>
>