Writing Device Drivers

Device Register Structure

Devices that do DMA have more registers than have been used in previous examples. This section adds the following fields to the device register structure to support DMA-capable device examples.

For DMA engines without scatter-gather support:

uint32_t				dma_addr;			/* starting address for DMA */
 uint32_t			dma_size;			/* amount of data to transfer */

For DMA engines with scatter-gather support:

	struct sglentry {
 		uint32_t				dma_addr;
 		uint32_t				dma_size;
 	} sglist[SGLLEN];
	caddr_t		 iopb_addr;			/* When written informs device of the next */
 										/* command's parameter block address. */
 										/* When read after an interrupt,contains */
 										/* the address of the completed command. */