Specifications

EXAMPLE 1 Using ddi_device_acc_attr() in ddi_regs_map_setup(9F)
(Continued)
*/
ddi_regs_map_setup(dip, rnumber, (caddr_t *)&dev_addr, offset, len,
&dev_attr, &handle);
/* read a 16-bit word command register from the device */
dev_command = ddi_getw(handle, dev_addr);
dev_command |= DEV_INTR_ENABLE;
/* store a new value back to the device command register */
ddi_putw(handle, dev_addr, dev_command);
EXAMPLE 2 Accessing a Device with Different Apertures
The following example illustrates the steps used to access a device with different
apertures. Several apertures are assumed to be grouped under one single "reg" entry.
For example, the sample device has four different apertures, each 32 Kbyte in size. The
apertures represent YUV little-endian, YUV big-endian, RGB little-endian, and RGB
big-endian. This sample device uses entry 1 of the "reg" property list for this purpose.
The size of the address space is 128 Kbyte with each 32 Kbyte range as a separate
aperture. In the register mapping setup function, the sample driver uses the offset and
len parameters to specify one of the apertures.
ulong_t *dev_addr;
ddi_device_acc_attr_t dev_attr;
ddi_acc_handle_t handle;
uchar_t buf[256];
...
/*
* setup the device attribute structure for never swap,
* unordered and 32-bit word access.
*/
dev_attr.devacc_attr_version = DDI_DEVICE_ATTR_V0;
dev_attr.devacc_attr_endian_flags = DDI_NEVERSWAP_ACC;
dev_attr.devacc_attr_dataorder = DDI_UNORDERED_OK_ACC;
/*
* map in the RGB big-endian aperture
* while running in a big endian machine
* - offset 96K and len 32K
*/
ddi_regs_map_setup(dip, 1, (caddr_t *)&dev_addr, 96*1024, 32*1024,
&dev_attr, &handle);
/*
* Write to the screen buffer
* first 1K bytes words, each size 4 bytes
*/
ddi_rep_putl(handle, buf, dev_addr, 256, DDI_DEV_AUTOINCR);
ddi_device_acc_attr(9S)
Data Structures for Drivers 29