2.3.2.4 DMA-Related Functions

A NIC driver calls NDIS functions for DMA operations between the host and the network interface card. For example, miniport NIC drivers allocate and manage virtual memory buffers in the host for DMA transfers. The NDIS library provides the functions that allow the drivers to allocate, construct, and inspect such buffers as described in the following table.

For busmaster DMA transfers, a NIC driver needs to send the physical addresses (also called logical addresses, since the actual microprocessor addresses are system mapped to device-accessible physical ranges) of virtual memory buffers to its network interface card. The driver can obtain these addresses by calling NdisMStartBufferPhysicalMapping. A portable miniport driver has limited use of logical addresses and sometimes only has knowledge of a virtual address when the network interface card requires a physical address. The NIC driver must call NDIS to map the virtual address to an appropriate logical address. The resultant mapping is temporary and the NIC driver must manage it using map registers.

Function

Definition

NdisMAllocateMapRegisters

Allocates map registers for use with busmaster DMA devices.

NdisMAllocateSharedMemory

Allocates memory to be shared between the system and a busmaster DMA NIC. It is called during driver initialization at IRQL PASSIVE_LEVEL.

NdisMAllocateSharedMemoryAsync

Called at raised IRQL, such as in a miniport’s HandleInterruptHandler, to allocate shared memory for a busmaster DMA NIC.

NdisMCompleteBufferPhysicalMapping

Releases the map registers used by a previous call to NdisMStartBufferPhysicalMapping for a busmaster DMA operation.

NdisMCompleteDmaTransfer

Indicates to the NDIS library that a slave DMA operation has completed.

NdisMDeregisterDmaChannel

Releases a miniport driver’s claim on its DMA channel.

NdisFlushBuffer

Called by the driver before sending data to the NIC or transferring data from the NIC to ensure coherence between cache memory and host physical memory during busmaster DMA operations.

NdisMFreeMapRegisters

Frees map registers for busmaster DMA that were previously allocated by NdisMAllocateMapRegisters.

NdisMFreeSharedMemory

Frees memory that was previously allocated by NdisMAllocateSharedMemory or NdisMAllocateSharedMemoryAsync.

NdisQueryMapRegisterCount

Returns the total number of map registers possible. The driver calls NdisQueryMapRegisterCount before calling NdisMAllocateMapRegisters to more realistically choose how many registers to allocate.

NdisMReadDmaCounter

Reads the current value of the system DMA controller counter.

NdisMRegisterDmaChannel

Sets up a DMA channel for future slave DMA operations.

NdisMSetupDmaTransfer

Sets up the host system DMA controller for a slave DMA transfer.

NdisMStartBufferPhysicalMapping

Creates a physical address mapping for a busmaster DMA operation.

NdisMUpdateSharedMemory

Ensures that data to be read from a shared memory region is up-to-date during busmaster DMA operations.