Writing Device Drivers

PCI Configuration

uint8_t pci_config_get8(ddi_acc_handle_t handle, off_t offset);
uint16_t pci_config_get16(ddi_acc_handle_t handle, off_t offset);
uint32_t pci_config_get32(ddi_acc_handle_t handle, off_t offset);
uint64_t pci_config_get64(ddi_acc_handle_t handle, off_t offset);
void pci_config_put8(ddi_acc_handle_t handle, 
			off_t offset, uint8_t value);
void pci_config_put16(ddi_acc_handle_t handle,  	
			off_t offset, uint16_t value);
void pci_config_put32(ddi_acc_handle_t handle,  	
			off_t offset, uint32_t value);
void pci_config_put64(ddi_acc_handle_t handle,  	
			off_t offset, uint64_t value);

These routines read or write a single datum of various sizes from or to the PCI local bus configuration space. The pci_config_get8(9F), pci_config_get16(9F), pci_config_get32(9F), and pci_config_get64(9F) functions read 8 bits, 16 bits, 32 bits, and 64 bits of data respectively. The pci_config_put8(9F), pci_config_put16(9F), pci_config_put32(9F), and pci_config_put64(9F) functions write 8 bits, 16 bits, 32 bits, and 64 bits of data respectively. The offset argument must be a multiple of the datum size.

Because the PCI local bus configuration space is represented in little-endian data format, these functions translate the data from or to native host format to or from little-endian format.

pci_config_setup(9F) must be called before invoking these functions.