[wdmaudiodev] Re: Doubt about MDL

  • From: <daniel@xxxxxxxxxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Thu, 22 Nov 2012 07:21:28 +0100

I will be allocating a buffer and create corresponding MDL by using function *AllocatePagesForMdl This method always allocates an integral number of pages from nonpaged pool.

It does not. It allocates physical memory, not virtual memory or pool. Even if at some point you will get virtual addresses for them, that will not be charged against nonpaged pool.

Does this mean that if i call *MmGetMdlByteOffset* with this MDL as i/p , the byteoffset returned by *MmGetMdlByteOffset* will always be zero?

Yes, it says it allocates an integral number of pages. That means a full first page.

Is there any possibility of getting non zero offset indicating that event though buffer is of say n pages the valid data starts at some non zero offset of first page?

No, it says it allocates an integral number of pages only.

Also when i allocate buffer using *AllocatePagesForMdl* is it guaranteed that all rest of the pages are fully allocated for my buffer

No. It does not guarantee that it allocates all pages that you request. If there are not enough free physical pages, it returns an MDL with the memory it could allocate. Therefore you need to check the returned MDL with the MmGetMdlByteCount function to see how much memory you actually received.

or do i need to traverse *PMDL**Next *element until mdl ends and find byte offset within each page using *MmGetMdlByteOffset* ?

That doesnât sound like a sensible thing to do.

//Daniel


******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: