The PCI property assigned-addresses provides vector entries that represent the physical addresses of devices on expansion cards. Apple has added another property-- AAPL,address --that provides a vector of 32-bit logical address values, where the n th value corresponds to the n th assigned-addresses vector entry. When accessing device functions located in memory space, you should use the corresponding AAPL,address property as the device's base. The same technique is recommended when you are accessing high-performance device functions in I/O space.
Using the AAPL,address property, a driver can find the logical address of an I/O resource. Accessing the logical address generates an I/O cycle on the PCI bus. Using the logical base address, a driver can generate a PCI I/O cycle in the same way it accesses a PCI device in memory space. This provides the fastest possible interface to I/O space. For sample code that illustrates this technique, see Listing 9-3.
To access a register in memory or I/O space using an AAPL,address property, do the following:
volatile UInt16 *gIORegisterBase;
value = gIORegisterBase[0x04 / sizeof (UInt16)];
As with memory accesses, you will need to byte swap the returned value to obtain a Macintosh big-endian result. Byte swapping routines are described in Byte Swapping Routines.
Between PCI I/O accesses, software must call the SynchronizeIO function to ensure that the accesses affect the PCI device in the correct order.