Writing Device Drivers

Check Changed Fields in DDI Data Structures

The data types of some of the fields within 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. Because 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_arq_status(9S)

uint_t        sts_rqpkt_state;             /* was type u_long */
uint_t        sts_rqpkt_statistics;        /* was type u_long */

These fields do not need to grow and have been redefined as 32-bit quantities.

scsi_pkt(9S)

uint_t      pkt_flags;               /* was type u_long */
int         pkt_time;                /* was type long */
ssize_t     pkt_resid;               /* was type long */
uint_t      pkt_state;               /* was type u_long */
uint_t      pkt_statistics;          /* was type u_long */

Because the pkt_flags, pkt_state, and pkt_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.