wrote in message news:xxxxx@ntdev… > Hi. > > I’m trying to write a low level NDIS driver. > The driver sends/receives data to/from a bus. > > I’d like to allocate DMA capable memory to be shared by my driver and the > bus driver (similarly to linux’s kmalloc with the GFP_DMA flag set) > > Could this be done using NdisMAllocateSharedMemory()?
Actually, I’ve got no idea how your driver " sends/receives data to/from a bus", but I suspect that you mean that this is a driver for a device with bus-mastering capability…
I’d like to allocate DMA capable memory to be shared by my driver and the bus driver (similarly
to linux’s kmalloc with the GFP_DMA flag set)
There is no such thing as “DMA capable memory” - this is just the question of whether a given device on a given bus is able to address a given physical range, which depends on device capabilities and bus width. Assuming Linux running x86 , the only thing GFP_DMA flag means is that memory should be allocated from the range that is accessible to ISA devices, i.e the first 16M of RAM .Assuming that I understood you properly and you are speaking about a device with bus-mastering capabilities (i.e. PCI, PCI-X or PCI-E one), GFP_DMA flag is the last thing you should be bothered about…
Could this be done using NdisMAllocateSharedMemory()?
Let’s look at what documentation says about it
[begin quote]
This function allocates and maps a host memory range so it is simultaneously accessible from both the system and a bus master direct memory access (DMA) network interface card (NIC).
[end quote]
It does not sound like “kmalloc with the GFP_DMA flag set”, does it -what it does sound like is dma_alloc_coherent(). Therefore, if a Linux driver that you are apparently trying to port to Windows uses dma_alloc_coherent(), NdisMAllocateSharedMemory() seems to be a suitable option…