Writing Device Drivers

Check Changed Fields in DDI Data Structures

The data type of some of the fields in DDI data structures such as buf(9S) have been changed. Drivers that use these data structures should make sure that these fields are being used appropriately. The data structures and the fields that were changed in a significant way are listed below.

buf(9S)

size_t   b_bcount;      /* was type unsigned int */
size_t   b_resid;       /* was type unsigned int */
size_t   b_bufsize;      /* was type long */
The fields changed here pertain to transfer size, which can now exceed more than 4GB in future systems.

ddi_dma_attr(9S)

This structure defines attributes of the DMA engine and the device. Since these attributes specify register sizes, fixed-width data types have been used instead of fundamental types.

ddi_dma_cookie(9S)

uint32_t     dmac_address;    /* was type unsigned long */
size_t     dmac_size;     /* was type u_int */
This structure contains a 32-bit DMA address, so a fixed-width data type has been used to define it. The size has been redefined as size_t.

scsi_pkt(9S)

u_int		pkt_flags;			/* was type u_long */
int			pkt_time;			/* was type long */
ssize_t	pkt_resid;			/* was type long */
u_int		pkt_state;			/* was type u_long */
u_int		pkt_statistics;	/* was type u_long */
Since the flags, state and statistics fields do not need to grow they have been redefined as 32-bit integers. The data transfer size pkt_resid field does grow and has been redefined as ssize_t.