Implementing DMA for NDIS Miniport Drivers

Direct memory access (DMA) is important for efficient networking because it enables the layers in the networking architecture to share data without first copying that data. Currently, Windows CE does not have any inherent DMA mechanisms; however, developers can implement equivalent functionality in their miniport drivers.

There are two categories of DMA: slave DMA and busmaster DMA. Slave DMA is appropriate for OEMs because it requires a block of memory that is pre-allocated in the device memory map of the Windows CE–based platform. Miniport drivers can map that block of physical memory to the driver’s virtual memory space, and then use the VirtualAlloc and VirtualCopy functions to move data in and out of that space. For an example of this type of DMA implementation for a Windows CE operating system for a Windows-based hardware development target platform, see the National Semiconductor IrDA sample driver.

Currently, no sample miniport driver implements busmaster DMA, which is a slightly more complex mechanism than slave DMA. To receive data, the driver allocates a shared memory block, transfers the data to buffers within that block, and uses NDIS functions to indicate that a packet has arrived. To send data, the driver uses the LockPages and UnlockPages functions to map the virtual memory to device memory, informs the NIC of the addresses of the data, and instructs the NIC to send the data. This method can be faster for larger data block sizes.