Writing Device Drivers

I/O Port Access

These interfaces support the accessing of device registers from the device driver.

uint8_t ddi_io_get8(ddi_acc_handle_t handle,  	
			int dev_port);
uint16_t ddi_io_get16(ddi_acc_handle_t handle,  	
			int dev_port);
uint32_t ddi_io_get32(ddi_acc_handle_t handle,  	
			int dev_port);

These routines generate a read of various sizes from the device port, developer, in I/O space. The ddi_io_get8(9F), ddi_io_get16(9F), and ddi_io_get32(9F) functions read 8 bits, 16 bits, and 32 bits of data respectively from the device port, dev_port.

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_io_rep_get8(ddi_acc_handle_t handle,  	
			uint8_t *host_addr, int dev_port, size_t repcount);
void ddi_io_rep_get16(ddi_acc_handle_t handle,  
				uint16_t *host_addr, int dev_port, size_t repcount);
void ddi_io_rep_get32(ddi_acc_handle_t handle,  	
			uint32_t *host_addr, int dev_port, size_t repcount);

These routines generate multiple reads from the device port, dev_port, in I/O space, repcount data is copied from the device port, dev_port, to the host address, host_addr. For each input datum, the ddi_io_rep_get8(9F), ddi_io_rep_get16(9F), and ddi_io_rep_get32(9F) functions read 8 bits, 16 bits, and 32 bits of data, respectively, from the device port. 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_io_put8(ddi_acc_handle_t handle,  	
			int dev_port, uint8_t value);
void ddi_io_put16(ddi_acc_handle_t handle,  	
			int dev_port, uint16_t value);
void ddi_io_put32(ddi_acc_handle_t handle,  	
			int dev_port, uint32_t value);

These routines generate a write of various sizes to the device port, dev_port, in I/O space. The ddi_io_put8(9F), ddi_io_put16(9F), and ddi_io_put32(9F) functions write 8 bits, 16 bits, and 32 bits of data, respectively, to the device port, dev_port.

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_io_rep_put8(ddi_acc_handle_t handle,  	
			uint8_t *host_addr, int dev_port, size_t repcount);
void ddi_io_rep_put16(ddi_acc_handle_t handle,  	
			uint16_t *host_addr, int dev_port, size_t repcount);
void ddi_io_rep_put32(ddi_acc_handle_t handle,  
			uint32_t *host_addr, int dev_port, size_t repcount);

These routines generate multiple writes to the device port, dev_port, in I/O space. repcount data is copied from the host address, host_addr, to the device port, dev_port. For each input datum, the ddi_io_rep_put8(9F), ddi_io_rep_put16(9F), and ddi_io_rep_put32(9F) functions write 8 bits, 16 bits, and 32 bits of data, respectively, to the device port. 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.