NdisAllocateMemoryWithTag(Priority) -> Does it ensure Congtiguous physical memory by default?

Discussion in 'Windows Vista Drivers' started by Praveen Kumar Amritaluru, Sep 18, 2008.

  1. Hi,

    NdisAllocateMemory has been obsoleted by NdisAllocateMemoryWithTag which in
    turn has been obsoleted by NdisAllocateMemoryWithTagPriority,
    as per the WDK for Vista(6.0) and above.

    The docs say that NdisAllocateMemoryWithTag(Priority) is same as
    NdisAllocateMemory() except that it allows the caller to supply a tag.

    But other differences are:
    1. No argument where you can specify flags?
    2. No "highest physical address" field.

    Now what is the default behaviour with NdisAllocateMemoryWithTag(Priority)?
    Does it always allocate physically contiguous memory? OR does it always
    make best effort to do so though its not guaranteed?
    What if there is a need for non-cached memory?

    I am not sure if the above requirements have been taken care of - in a
    different way in NDIS 6.0.

    Praveen Kumar Amritaluru, Sep 18, 2008
    1. Advertisements

  2. DMA_OPERATIONS->AllocateCommonBuffer() seems to be allocating physically
    contiguous bufer.
    Is there an equivalent Ndis() since NdisAllocateMemory() is obsoleted on
    Vista and above?

    Also is there an Ndis() or any equivalent call to specify the range of
    physical address?
    Basically highest accetable physical address?

    Praveen Kumar Amritaluru, Sep 18, 2008
    1. Advertisements

  3. Praveen Kumar Amritaluru

    Pavel A. Guest

    NdisAllocateMemoryWithTag(Priority) allocates nonpaged pool.
    Therefore it is not physically contiguous and not limited
    by "highest physical address".

    For allocation of DMA shared memory use NdisMRegisterScatterGatherDma;
    it lets you specify 32- or 64-bit capability of the NIC.

    Pavel A., Sep 18, 2008
  4. OK. Let me put the requirements clearly.
    My earlier mail is not clear I suppose.

    The requirement is that from within driver memory allocation needs to be
    that falls within a range. One example requirement is when we want memory
    such that physical address contains non-zero bits in higher 32 bit (of
    64-bit physical address)
    to test the handling of device that is supposed to handle physical memory
    more than 4 GB (> 32 bits).

    I am trying to figure if there is one or set of NDIS calls that can do this.

    With NdisMRegisterScatterGatherDMA I can only say that dont give 64-bit
    addresses since my device only supports 32-bit.
    Even I say my device supports 64-bit, there is no guarantee that memory
    allocated to my device falls above 4 GB.

    Praveen Kumar Amritaluru, Sep 18, 2008
  5. Praveen Kumar Amritaluru

    Pavel A. Guest

    Maybe /nolowmem boot option is what you need?
    (described in windbg help file)

    Pavel A., Sep 18, 2008
  6. Hi Pavel,

    But this needs special hardware (system with PAE support running x86
    version of OS) which is not necessarily
    the case with a developer's test-system.

    But this info is helpful though.

    Praveen Kumar Amritaluru, Sep 18, 2008
  7. I believe in W2K8 if your device does 64 bit DMA, when you call
    NdisMAllocateSharedMemory you will get high physical addresses before
    getting low addresses (system tries to reserve low addresses for those
    devices that can not do 64 bit DMA.).

    Have you tried NdisAllocateSharedMemory to see what address range you get?

    NDIS does not provide an API to allocate physically contiguous memory
    outside what HAL DMA APIs provide (NdisMAllocateSharedMemory is a wrapper
    around DmaChannel->AllocateCommonBuffer). There is a very good reason for
    this. DMA APIs take into account what your device can address. mm APIs that
    allow you to allocate physical address directly have no idea of the device
    capabilities (there is no PDO parameter). Going forward it will become even
    more important to go through HAL DMA APIs to allocate physical addresses.

    In any case, seems like you just need this for testing purpose. If what I
    said about W2K8 turns out to be false, just allocate as much memory as you
    can in your driver. At some point the physical address would end up going
    over 32 bit.

    Alireza Dabagh [MS], Sep 19, 2008
  8. I think DTM and DriverVerifier test that.

    Alexander Grigoriev, Sep 19, 2008
  9. We currently use HAL DMA APIs/NdisAllocatedSharedMemory() to allcoate shared

    I have not tried looking at what range of address is being provided on W2K8.
    I will check it up on W2K8.

    Thanks for the information.
    Praveen Kumar Amritaluru, Sep 22, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.