Writing Device Drivers

Memory Space Access

uint8_t ddi_mem_get8(ddi_acc_handle_t handle, uint8_t *dev_addr);
uint16_t ddi_mem_get16(ddi_acc_handle_t handle, uint16_t *dev_addr);
uint32_t ddi_mem_get32(ddi_acc_handle_t handle, uint32_t *dev_addr);
uint64_t ddi_mem_get64(ddi_acc_handle_t handle, uint64_t *dev_addr);

These routines generate a read of various sizes from memory space or allocated DMA memory. The ddi_mem_get8(9F), ddi_mem_get16(9F), ddi_mem_get32(9F), and ddi_mem_get64(9F) functions read 8 bits, 16 bits, 32 bits, and 64 bits of data respectively from the device address, dev_addr, in memory space.

Each individual datum is automatically translated to maintain a consistent view between the host and the device, based on the encoded information in the data access handle. The translation may involve byte-swapping if the host and the device have incompatible endian characteristics.

void ddi_mem_put8(ddi_acc_handle_t handle, 
			uint8_t *dev_addr, uint8_t value);
void ddi_mem_put16(ddi_acc_handle_t handle, 
			uint16_t *dev_addr, uint16_t value)
void ddi_mem_put32(ddi_acc_handle_t handle, 
			uint32_t *dev_addr, uint32_t value);
void ddi_mem_put64(ddi_acc_handle_t handle, 
			uint64_t *dev_addr, uint64_t value);

These routines generate a write of various sizes to memory space or allocated DMA memory. The ddi_mem_put8(9F), ddi_mem_put16(9F), ddi_mem_put32(9F), and ddi_mem_put64(9F) functions write 8 bits, 16 bits, 32 bits, and 64 bits of data respectively to the device address, dev_addr, in memory space.

Each individual datum is automatically translated to maintain a consistent view between the host and the device, based on the encoded information in the data access handle. The translation may involve byte-swapping if the host and the device have incompatible endian characteristics.

void ddi_mem_rep_get8(ddi_acc_handle_t handle,  
			uint8_t *host_addr, uint8_t *dev_addr, size_t repcount, 
			uint_t flags);
void ddi_mem_rep_get16(ddi_acc_handle_t handle,  	
			uint16_t *host_addr, uint16_t *dev_addr,
 		size_t repcount, uint_t flags);
void ddi_mem_rep_get32(ddi_acc_handle_t handle,  	
			uint32_t *host_addr, uint32_t *dev_addr, size_t repcount, 
			uint_t flags);
void ddi_mem_rep_get64(ddi_acc_handle_t handle,  	
			uint64_t *host_addr, uint64_t *dev_addr, size_t repcount, 
			uint_t flags);

These routines generate multiple reads from memory space or allocated DMA memory. repcount data is copied from the device address, dev_addr, in memory space to the host address, host_addr. For each input datum, the ddi_mem_rep_get8(9F), ddi_mem_rep_get16(9F), ddi_mem_rep_get32(9F), and ddi_mem_rep_get64(9F) functions read 8 bits, 16 bits, 32 bits, and 64 bits of data respectively from the device address, dev_addr. dev_addr and host_addr must be aligned to the datum boundary described by the function.

Each individual datum is automatically translated to maintain a consistent view between the host and the device, based on the encoded information in the data access handle. The translation may involve byte-swapping if the host and the device have incompatible endian characteristics.

void ddi_mem_rep_put8(ddi_acc_handle_t handle,  	
			uint8_t *host_addr, uint8_t *dev_addr, size_t repcount, 
			uint_t flags);
void ddi_mem_rep_put16(ddi_acc_handle_t handle,  	
			uint16_t *host_addr, uint16_t *dev_addr, size_t repcount, 
			uint_t flags);
void ddi_mem_rep_put32(ddi_acc_handle_t handle,  	
			uint32_t *host_addr, uint32_t *dev_addr, size_t repcount, 
			uint_t flags);
void ddi_mem_rep_put64(ddi_acc_handle_t handle,  	
			uint64_t *host_addr, uint64_t *dev_addr, size_t repcount, 
			uint_t flags);

These routines generate multiple writes to memory space or allocated DMA memory. repcount data is copied from the host address, host_addr, to the device address, dev_addr, in memory space. For each input datum, the ddi_mem_rep_put8(9F), ddi_mem_rep_put16(9F), ddi_mem_rep_put32(9F), and ddi_mem_rep_put64(9F) functions write 8 bits, 16 bits, 32 bits, and 64 bits of data respectively to the device address. dev_addr and host_addr must be aligned to the datum boundary described by the function.

Each individual datum is automatically translated to maintain a consistent view between the host and the device, based on the encoded information in the data access handle. The translation may involve byte-swapping if the host and the device have incompatible endian characteristics.