Writing Device Drivers

Managing Differences in Device and Host Endianness

The data format of the host can have different endian characteristics than the data format of the device. If this is the case, data transferred between the host and device needs to be byte swapped to conform to the data format requirements of the destination location. Other devices can have the same endian characteristics of the host and require no byte swapping of the data.

Drivers specify the endian characteristics of the device by setting the appropriate flag in the ddi_device_acc_attr(9S) structure that is passed to ddi_regs_map_setup(9F). The DDI framework then performs any required byte swapping when the driver calls a ddi_getX routine (such as ddi_get8(9F)) or a ddi_putX routine (such as ddi_put16(9F)) to read or write device memory.