Writing Device Drivers

Change Common Access Functions to Fixed-Width Versions

Previously, DDI common access functions specified the size of data in terms of bytes, words, and so on. For example, ddi_getl(9F) was used to access 32-bit quantities. This function will not work to access a 32-bit quantity in the 64-bit environment because long is now a 64-bit quantity.

In Solaris 2.6, new common access functions that use fixed-width types have been added. These functions have been named to reflect the actual data size. For example, in a 64-bit environment, a driver must use ddi_get32(9F) to access 32-bit data rather than ddi_getl(9F).

	uint32_t ddi_get32(ddi_acc_handle_t hdl, uint32_t *dev_addr); 

To make a device driver 64-bit safe, replace all Common Access functions with the new fixed-width versions.

Table F-2 shows a subset of the new common access functions. For a complete list of the new functions, see Appendix B, Interface Transition List. For a brief description of the new interfaces, see Appendix C, Summary of Solaris 7 DDI/DKI Services.

Table F-2 Solaris 7 Common Access Functions


reads 8 bits from device address 


reads 16 bits from device address 


reads 32 bits from device address 


reads 64 bits from device address 


writes 8 bits to device address 


writes 16 bits to device address 


writes 32 bits to device address 


writes 64 bits to device address